in reply to Re: Help with regex
in thread Help with regex
Then there's the issue of idiomatic usage, which may or may not lead one to use $_, implicit matching against $_, or 'for' instead of 'foreach', depending one their views. This leads to code about as legible as the previous for many Perl coders, but I think it's fair to call it a matter of preference.foreach $line ( @fileData ) { $linenumber++; if ( $line =~ m/^1$/) { print "$linenumber\n"; } }
Which shouldn't be confused at all with golf, which does hinder legibility somewhat.for ( @fileData ) { $linenumber++; if ( m/^1$/ ) { print "$linenumber\n"; } }
$l++,/^1$/&&print$l.$/for@f;
|
|---|