Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: Parsing "=" separated output

by johngg (Canon)
on Aug 03, 2011 at 09:46 UTC ( [id://918211]=note: print w/replies, xml ) Need Help??


in reply to Re: Parsing "=" separated output
in thread Parsing "=" separated output

Unfortunately, with the look-ahead you would miss the last entry in your example

Just put an alternation in the look-ahead to cope with end of string.

knoppix@Microknoppix:~$ perl -MData::Dumper -Mstrict -wE ' > my $str = > q{sometrash key1=value0 value1, value2 key2=value3 key3=value4}; > my %data = $str =~ m{([^\s=]+)=(.*?)(?=(?:\s+[^\s=]+=|\z))}g; > print Data::Dumper->Dumpxs( [ \ %data ], [ qw{ *data } ] );' %data = ( 'key2' => 'value3', 'key1' => 'value0 value1, value2', 'key3' => 'value4' ); knoppix@Microknoppix:~$

I hope this is of interest.

Update: I just realised this is in essence exactly the same as Utilitarian's reply. Please ignore.

Cheers,

JohnGG

Log In?
Username:
Password:

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

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

    No recent polls found