I don't believe this would work. Firstly,

Doesn't matter, poulate @explicit however you like

Secondly, Will ensure the store(i.e the key) will only have the last product read from the input.

Is this important?

This is how you're supposed to use map, to create lists -- if you're not doing that stick with foreach (or to save memory stick with while)

If all you want is to treat it like foreach, you can use it in void context, but its not recommended, it clouds the purpose, and on older perls its not efficient

#!/usr/bin/perl -- use strict; use warnings; use Data::Dump qw/ dd pp /; open my($fh),'<', \<<'__FUDGE__' or die; STORE PRODUCT_ID ==================== Sydney 12 Sydney 14 Canberra 12 Canberra 18 __FUDGE__ my %hash; $hash{(split)[0]}{(split)[1]} = 1 while <$fh>; seek $fh, 0, 0; dd\%hash; undef %hash; map { my @explicit = split ' ', $_; 2 == @explicit ## ==== and $hash{ $explicit[0] }{ $explicit[1] }++; (); } <$fh>; dd\%hash; __END__ $ perl fudge Use of uninitialized value in hash element at fudge line 16, <$fh> lin +e 6. { "====================" => { "" => 1 }, "Canberra" => { 12 => 1, 18 => 1 }, "STORE" => { PRODUCT_ID => 1 }, "Sydney" => { 12 => 1, 14 => 1 }, } { Canberra => { 12 => 1, 18 => 1 }, STORE => { PRODUCT_ID => 1 }, Sydney => { 12 => 1, 14 => 1 }, }

In reply to Re^5: Possible for Map to create Hash of Hash? by Anonymous Monk
in thread Possible for Map to create Hash of Hash? by konnjuta

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.