Well, here's what I came up with when I tried to solve it myself without looking at the other answers first. Not that innovative, but I will observe, for me at least, it seems to be easier to deal with hash refs and array refs than hash/arrays. Why this seems cleaner? I'm not sure if this is a syntactical thing or psychological thing, or a little of both, or just a quirk of mine, but at any rate:
my $param_hash;
foreach my $nar (@nar) {
my ( $cwd, $prm ) = split( " - ", $nar->[0] );
my $rest = [ @$nar[ 1 .. 2 ] ];
push @{ $param_hash->{$cwd}->{$prm} }, $rest;
}
print Dumper $param_hash;
I would also like to ask
neversaint, did you clean up the D::D output, or did it really come out like that? I tried
$Data::Dumper::Indent = 0, but everything just spewed out on one line. Indent = 1 or more, and it split over too many lines, like in holli's output above. So, if there's a way to do this, please share. Thanks!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.