On Mon, 2008-09-22 at 20:37 +0530, Sharan Basappa wrote:
> I have a code snippet as follows:
>
> keyword id1 = a x b x c;
> keyword id2 = c x d x e;
>
> I would like to extract strings "a x b x c" and "c x d x e". I know I
> can loop through the
> code and extract the strings, but is there a RE that can do this with
> a single statement.
> My first guess was to use /s modifier but I am not sure.
The /s flag tells the RE to allows '.' to match "\n" too.
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
$Data::Dumper::Sortkeys = 1;
$Data::Dumper::Indent = 1;
$Data::Dumper::Maxdepth = 0;
my $text = undef;
{
local $/;
$text = <>;
}
my @capture = $text =~ m{=\s*(.*?)\s*;}gms;
print Dumper [EMAIL PROTECTED];
__END__
--
Just my 0.00000002 million dollars worth,
Shawn
Linux is obsolete.
-- Andrew Tanenbaum
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/