inblosam has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; use Data::Dumper; my $rawdata = qq| <COLUMNS>~ItemName1~ItemName2~ItemName3~ItemName4~ItemName5~</COLUMNS> <DATA>~Apple~Orange~Banana~Pear~Watermelon~</DATA> <DATA>~Blue~Red~Yellow~Brown~Purple~</DATA> <DATA>~Uno~Dos~Tres~Cuatro~Cinco~</DATA> |; my @datalines = split("\n",$rawdata); my @listings; my $header; foreach my $line (@datalines) { if ($line =~ /^<COLUMNS>(.+)<\/COLUMNS>/xg) { $header = $1; } elsif ($line =~ /^<DATA>(.+)<\/DATA>/xg) { push(@listings, $1); } } print Dumper(\$header); print Dumper(\@listings);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Complicated Hash with array
by GrandFather (Saint) on Aug 08, 2006 at 05:05 UTC | |
by inblosam (Monk) on Aug 08, 2006 at 12:34 UTC | |
by Hofmator (Curate) on Aug 08, 2006 at 12:47 UTC | |
by inblosam (Monk) on Aug 08, 2006 at 19:46 UTC |