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

Re^5: Split and print hash based on regex

by AnomalousMonk (Archbishop)
on Mar 28, 2018 at 15:09 UTC ( [id://1211927]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Split and print hash based on regex
in thread Split and print hash based on regex

choroba is not wrong to write here that "... without a capture group in the regex, there's no way to populate $1." But as always with regexes, it's more complicated:

c:\@Work\Perl\monks>perl -wMstrict -le "$_ = 'This is not an exit'; ;; if (my ($regex) = /This is/g) { print qq{matched, captured '$regex'}; } " matched, captured 'This is'
Due to the influence of the  /g modifier, something is captured, it's just not anything useful | useful in this case. The only purpose the capture serves in the second OPed SSCCE (the one added in an update) would be to produce a perplexing error message if the open operation failed in the
    open ... or die "could not open 'UserA$regex.txt' $!";
statement. See Matching in list context in perlop.


Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (8)
As of 2024-04-25 11:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found