Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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]
[choroba]: LanX I can show you what I can do with magit

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (10)
As of 2017-08-18 13:58 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (303 votes). Check out past polls.