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

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

by ambrus (Abbot)
on Jul 30, 2006 at 22:36 UTC ( #564664=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    perl -we 'use Data::Dumper; $s = \%p; @s = (); while (<>) { our $f++ o
    +r $_ = ": " . $_; while (/\G\s*(?:([-\w.]+|"[^"]*")|:([-\w.]*)\s*\(|(
    +\)))/gc) { if (defined($1)) { defined($$s{""}) and die "parse error: 
    +two"; $$s{"@"} = $1; } elsif (defined($2)) { push @s, $s; $s = $$s{$2
    +} = {}; } elsif (defined($3)) { @s or die "parse error: close"; $s = 
    +pop @s; } } /(\S.*)/g and die "parse error: junk: $1"; } $! and die "
    +read error"; $s == \%p or die "parse error: open"; print Dumper(\%p);
    +'
    
  2. or download this
    (demo
        :type (device)
    ...
        )
    )
    
  3. or download this
    use warnings; use strict;
    use Data::Dumper;
    ...
    my $p = parse(*ARGV);
    print Dumper($p);
    __END__
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (14)
As of 2014-04-16 15:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (432 votes), past polls