Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
Keep It Simple, Stupid
 
PerlMonks  

Re^2: How to improve regex for parsing equals delimited data

by tobyink (Prior)
on May 11, 2012 at 07:34 UTC ( #969923=note: print w/ replies, xml ) Need Help??


in reply to Re: How to improve regex for parsing equals delimited data
in thread How to improve regex for parsing equals delimited data

Hmmm... I wish that the result of a pre-increment was an lvalue. That would allow this:

my %x = (field => $F[$_ - 1], value => $F[$_]);

to become this...

my %x = (field => $F[(--$_)++], value => $F[$_]);

or maybe even...

my %x = (field => $F[--$_++], value => $F[$_]);

Now that would be a fun idiom! As things stand, this works:

my %x = (field => $F[--$_], value => $F[++$_]);

That said, my initial boring version is probably more readable.

Update: I've just remembered the secret inchworm-on-a-stick operator. This is one of those rare opportunities it's actually useful:

my %x = (field => $F[~-$_], value => $F[$_]);
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'


Comment on Re^2: How to improve regex for parsing equals delimited data
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (10)
As of 2013-05-23 16:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best material for plates (tableware) is:









    Results (486 votes), past polls