Re: Pattern matching line by line

2004-06-16 Thread Jeff 'japhy' Pinyan
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

RE: Pattern matching line by line

2004-06-16 Thread Marcos . Rebelo
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