in reply to Re^2: OptiPerls Pattern Replace (Regexpses for one Line)
in thread OptiPerls Pattern Replace (Regexpses for one Line)
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
|
|---|