If you read your code in line by line, which is the normal way in perl, the special variable $_ matches the current line automatically, so you don't need a regex to match it.
Or, I guess,
^.*$
will also match an entire line if you have to use a regex. Or
blah.*$
will match everything from the first blah out to the end of the line.
Or maybe you could rephrase the question if that isn't quite what you wanted.
use warnings; use strict; while (<DATA>) { print '$_: ' . "$_"; /^.*$/; print '/^.*$/: ' . "$&\n"; # print the match /blah.*$/; print '/blah.*$/: ' . "$&\n"; print "\n"; } #outputs: #$_: blah #/^.*$/: blah #/blah.*$/: blah # #$_: foo blah #/^.*$/: foo blah #/blah.*$/: blah # #$_: foo bar blah blah blah #/^.*$/: foo bar blah blah blah #/blah.*$/: blah blah blah # #$_: #/^.*$/: #/blah.*$/: __DATA__ blah foo blah foo bar blah blah blah
In reply to Re: OptiPerls Pattern Replace (Regexpses for one Line)
by tphyahoo
in thread OptiPerls Pattern Replace (Regexpses for one Line)
by Ben Win Lue
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |