Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Logic trouble parsing a formatted text file into hashes of hashes (of hashes, etc.)

by ambrus (Abbot)
on Oct 16, 2004 at 20:31 UTC ( #399813=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use Data::Dumper; $s = \%p; @s = (); while (<>) { while (/\G\s*(?:([-\
    +w.]+)|:([-\w.]+)\s*\(|(\)))/gc) { if (defined($1)) { defined($$s{""})
    + and die "parse error: two"; $$s{""} = $1; } elsif (defined($2)) { pu
    +sh @s, $s; $s = $$s{$2} = {}; } elsif (defined($3)) { @s or die "pars
    +e error: close"; $s = pop @s; } } /(\S.*)/g and die "parse error: jun
    +k: $1"; } $! and die "read error"; $s == \%p or die "parse error: ope
    +n"; print Dumper(\%p);
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (10)
As of 2014-08-29 12:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (280 votes), past polls