use warnings; use strict; while (<DATA>) { #everything before the # /^[^#]*/; print 'everything before the #: ' . "$&\n"; #everything from the # to the end of the line /#.*/; print '/#.*/: ' . "$&\n"; print "\n"; } #outputs: #everything before the #: blah #/#.*/: #this is a comment # #everything before the #: foo blah #/#.*/: #this is a comment # #everything before the #: foo bar blah blah blah #/#.*/: #this is a comment # #everything before the #: # #/#.*/: # __DATA__ blah #this is a comment foo blah #this is a comment foo bar blah blah blah #this is a comment
In reply to Re^3: OptiPerls Pattern Replace (Regexpses for one Line)
by tphyahoo
in thread OptiPerls Pattern Replace (Regexpses for one Line)
by Ben Win Lue
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |