Understanding with this regex in Perl without assigment -
can explain me how understand part of code code extracted pflogsumm.pl log analyzer postfix mail
while(<>) { next if(defined($datestr) && ! /^$datestr/o); s/: \[id \d+ [^\]]+\] /: /o; # lose "[id nnnnnn some.thing]" stuff $logrmdr; more code }
i can't undestand regex doing because don't have assigment, don't have conditional, simple there
thanks
by default, regular expressions (and many other functions) operate on $_
.
s/: \[id \d+ [^\]]+\] /: /o;
is equivalent to:
$_ =~ s/: \[id \d+ [^\]]+\] /: /o;
this replaces : [id number ...]
:
in input line.
this mutual idiom should see in many perl scripts, should used it.
regex perl
No comments:
Post a Comment