Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: A regex BR variable dead in following line/command

by roboticus (Chancellor)
on Nov 12, 2021 at 13:49 UTC ( [id://11138757]=note: print w/replies, xml ) Need Help??


in reply to A regex BR variable dead in following line/command

abdan:

If you want to keep it, then store it in a variable:

my $x = .... do { if ($whole =~ /^(.*?)^(\*{5,}..?^\*SRC)/mscg) { print "\n=======\n".$1."\n=======\n".$2; $x = $2; } } while($x);

The capture group variables are set every time you do a match. Can you imagine how annoying it would be if they weren't? Then you'd have to explicitly clear them before doing a match or you'd risk getting bits of old data mixed in with new data. The current automatic clearing of the group variables is a much better match to typical expected behavior.

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11138757]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-03-28 18:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found