sreeman78
asked on
Pattern match
Hi,
I want to grep the value presnt inside <sql type="cognos"> XXXXX</sql>
in the attached file there are 98 occurences .
I want to grep this value (XXXXX) and push it inside an array .So that that array would contain all the XXXXX .I am attaching the file <model.xml>
my code
my $infile = shift;
open INFILE, "<", $infile;
$count=0;
while ($in = <INFILE>) {
#print if (/<dataSourceRef>.*<\/data SourceRef> /);
($input) = $in =~ (/<sql type="cognos">(.*?)<\/sql> /);
push @array,$input;
}
close INFILE;
print scalar @array ;
print join ("\n","@array\n");
model.xml
I want to grep the value presnt inside <sql type="cognos"> XXXXX</sql>
in the attached file there are 98 occurences .
I want to grep this value (XXXXX) and push it inside an array .So that that array would contain all the XXXXX .I am attaching the file <model.xml>
my code
my $infile = shift;
open INFILE, "<", $infile;
$count=0;
while ($in = <INFILE>) {
#print if (/<dataSourceRef>.*<\/data
($input) = $in =~ (/<sql type="cognos">(.*?)<\/sql>
push @array,$input;
}
close INFILE;
print scalar @array ;
print join ("\n","@array\n");
model.xml
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
($input) = $in =~ (/<sql type="cognos">(.*?)<\/sql>