in reply to General Question on parsing a variable
You will find it easier to access the records if you read them into a suitable data structure first. In Perl, that usually means a hash:
my %hash; $hash{$1} = $2 while $var =~ /storeID = (\d+)\s+(.*?)end/gs;
Then you can search like this:
my $criterion = ...; print "storeID = $_\n", $hash{$_} for grep { $hash{$_} =~ /$criterion/ + } keys %hash;
Hope that helps,
Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: General Question on parsing a variable
by diamondsandperls (Beadle) on Feb 07, 2013 at 16:06 UTC | |
by Athanasius (Archbishop) on Feb 07, 2013 at 16:55 UTC |
In Section
Seekers of Perl Wisdom