On Jun 16, bzzt said:
>I'm trying to match a patern in a string but I want to do it a line at a
>time. Is there an easier way than this :
>while ($a =~ m/(.+?)\n/g ) {
> if ($1 =~ /whatever/g) {
>print "$1";
> }
Your regex, /(.+?)\n/, is unnecessarily complex. The ? modifier on .+
isn't
why not to split the String first
something like
foreach my $line (split(/\n/, $a)) {
if ($line =~ /whatever/) {
print $line;
}
}
shall do the trick
Marcos
> -Original Message-
> From: bzzt [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, June 16, 2004 1:33 PM
> To: [EMAIL PROT