Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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 examining the Monastery: (16)
As of 2014-07-29 19:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (226 votes), past polls