Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: hashes recursively

by Jasper (Chaplain)
on Jun 09, 2006 at 13:52 UTC ( #554499=note: print w/ replies, xml ) Need Help??


in reply to hashes recursively

sub hasher { shift(), (@_ ? $#_ ? { &hasher } : @_ : return) } my %hash; while (<DATA>) { chomp; my @a = hasher(split /=/); $hash{ $a[0] } = $a[1] if @a == 2; } use Data::Dumper; print Dumper \%hash; __DATA__ a = ID = 1234 = this is the next bit = fifteen = 19.168.0.2 <<Start of info>> b=Gadens_Melb c= d= e=2006-03-27 15:10:06 f= ContactSensor:INPUT2 g=Critical h=Event-101 fatal stack error on PRI 001

gives me
$VAR1 = { 'e' => '2006-03-27 15:10:06', 'a ' => { ' ID ' => { ' 1234 ' => { ' this is the next bit ' + => { + ' fifteen ' => ' 19.168.0.2' + } } } }, 'h' => 'Event-101 fatal stack error on PRI 001', 'g' => 'Critical', 'b' => 'Gadens_Melb', 'f' => ' ContactSensor:INPUT2' };
That looks like what you wanted. Dunno how it works, though.


Comment on Re: hashes recursively
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2015-07-03 17:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (55 votes), past polls