Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: Help on parsing

by umasuresh (Hermit)
on Nov 17, 2010 at 20:34 UTC ( #872052=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Help on parsing
in thread Help on parsing

Below is something to start with. Requires some effort from your side to completion. Good Luck!

use strict; use Data::Dumper; my %hash; my $header_info; DAT: while (<DATA>) { next if !length($_); # ignore empty lines if ($_ =~ /^([A-Z]+)\|/) # capture the header { ($header_info) = $1; next DAT; } my($key, $value) = split /\|/, $_; $hash{$header_info}{$key} = $value; } #print Dumper(\%hash); for my $key1 (sort keys %hash) { for my $key2 ( sort keys %{ $hash{$key1} }) { print "$key1:$key2:$hash{$key1}{$key2}\t"; } print "\n"; } __DATA__ JAN| graph|104| success|100| on_time|100| environment|1| builder|3| design|0| FEB| graph|95| success|100| on_time|100| environment|1| builder|3| design|0|


Comment on Re^3: Help on parsing
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2015-07-04 20:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls