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 PROTECTED]
> Subject: Pattern matching line by line
>
>
> 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";
> }
>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>