Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

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 musing on the Monastery: (5)
As of 2016-02-12 05:06 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (388 votes), past polls