Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: hash magic

by sundialsvc4 (Abbot)
on Mar 14, 2013 at 13:30 UTC ( #1023476=note: print w/replies, xml ) Need Help??

in reply to hash magic

Perl to the rescue!   Read up on the topic of auto-vivification, which is a fancy-pants way of saying that something “just springs to life automatically.”   Hash structures of fairly arbitrary complexity can be fairly instantly built that way.

For example, consider:

Without you doing anything out-of-the-way at all, $foo will become a hashref and, just like that, it will have a key 1 which contains a hashref with a key a ... and so on ... and at the tail of the thing will be the number 1, filed under foobar, because that key sprang into existence with the value zero (which is what it needs to be because it’s about to be incremented), which got incremented by the ++ operator.   If you execute the statement again, well, the entire data structure already exists, and now the value at the tail of it is 2.

If that ain’t magic, I don’t know what is.   You will just need to craft a regular-expression to pull the string apart, then you can just write the one statement to create the entire data structure, and it will “just work.™”

Replies are listed 'Best First'.
Re^2: hash magic
by Anonymous Monk on Mar 14, 2013 at 13:39 UTC

    Perl to the rescue! ...

    That is not Perl, that is English

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1023476]
[jdporter]: I for one think it's kind of ridiculous that people can't ask - here - other people for help just because it involves monetary compensation.
[jdporter]: I think the test for whether to push it to should be strict: (a) you're looking for employment, or (b) you're looking to hire an employee or contractor.

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2017-03-23 01:11 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (278 votes). Check out past polls.