use strict; my (@up, @down, @labels); while (<DATA>) { chomp; if (/Peripherals Down:$/i .. /Peripherals Up:$/i) { next if /^$|^-{4}|Peripherals /; if (/^name/i){ @labels = split /\s\s+/; next; } my %h; @h{@labels} = split /\s\s+/; push @down, \%h; }else { next if /^$|^-{4}/; if (/^name/i){ @labels = split /\s\s+/; next; } my %h; @h{@labels} = split /\s\s+/; push @up, \%h; } } use Data::Dump qw/pp/; print "Down: $/"; pp @down; print "Up: $/"; pp @up; __DATA__ Peripherals Down: Name Host Port Category Priority + Monitor Type IS Managed Down time ---- ---- ---- -------- -------- + ------------ ----------- ------------ Christine 62.01.22.100 0 ABC company High + Ping Yes Thu Dec 16 06:35:07 PST 2004 Clark 72.03.100.89 0 XYZ company Low + Ping Yes Thu Dec 16 06:35:16 PST 2004 Peripherals Up: Name Host Port Category Priority + Monitor Type IS Managed Up time ---- ---- ---- -------- -------- + ------------ ----------- --------- Laston 100.02.99.211 0 XYZ company Medium + Ping Yes Thu Dec 16 06:35:27 PST 2004
In reply to Re: Parsing email and returning the key/values in two hashes
by olivierp
in thread Parsing email, inserting into database and creating an aggregation report.
by Alligator
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |