Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: regex question

by Corion (Pope)
on Apr 01, 2020 at 17:16 UTC ( #11114913=note: print w/replies, xml ) Need Help??


in reply to regex question

The match runs to completion before the map even starts.

At the time your map runs, $1 and $2 are what they are at the end of the global match.

Most likely you want pairs from List::Util:

foreach my $pair ( pairs /(\d+)\s+(\S+)/mg ) { my ( $key, $value ) = @$pair; ... }

... or a while loop:

$h{ $1 } = $2 while /(\d+)\s+(\S+)/mg;

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2020-05-31 17:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (175 votes). Check out past polls.

    Notices?