( , ):
-:
: Perl; , .
do { ... } , ($&, $1,...), .
, do { ... }, ( , , , ); :
$_="this is the man that made the new year rumble";
/ (is) /;
$do1 = do { / (made) / && $1 };
print "\$1 == '$1'; \$do1 == '$do1'\n";
- The advantage of this approach is that no current special regular expression variables are set or changed; the accepted answer, by contrast, changes variables such as
$&and $'. - The disadvantage is that you must explicitly exclude the variables of interest; however, you get the result of the default mapping operation, and if you are only interested in the contents of the capture buffers, that will be enough.
source
share