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

Re^3: Using a regex to replace looping and splitting

by Cristoforo (Curate)
on Jan 24, 2018 at 02:55 UTC ( #1207794=note: print w/replies, xml ) Need Help??


in reply to Re^2: Using a regex to replace looping and splitting
in thread Using a regex to replace looping and splitting

Hi,

'Dumper' is exportwd by Data::Dumper. 'pp' is exported by Data::Dump.

I think you are missing the distinction of the implied '$_' variable via the regex. it would look like my %hash = $_ =~ /([^|:]+):([^|:]+)(?:\z|\|)/g; You can just drop the '$_' in this case like he did.

For your third question, the proper form using the '$big_string' var (instead of '$_') would be my %hash = $big_string =~ /([^|:]+):([^|:]+)(?:\z|\|)/g;

For your last question, the regex captures the 2 colon separated values that are immediately followed by the end of string, ('\z'), or by a pipe. He writes that using a non-capturing group, (?: ... ).

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2020-09-24 15:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I donít succeed, I Ö










    Results (134 votes). Check out past polls.

    Notices?