Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

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
        :type (device)
  3. or download this
    use warnings; use strict;
    use Data::Dumper;
    my $p = parse(*ARGV);
    print Dumper($p);

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2016-10-27 17:21 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (366 votes). Check out past polls.