I'm trying to use (for the first time) a hash of anonymous hashes to hold a set of data records from a delimited flat ascii file. I will at some point need to add, edit, and delete records from this set but they must be put back into this flat file as other applications use this file.
Currently we use vi to manage these data and all kinds of problems are introduced using vi.

The code I'm working with(doesn't work) is as follows:

#!/usr/bin/perl -w use strict; our %rets; open(RL, "</home/myftplog") || open (RL, "<h:\\myftplog") || die "$!\n"; while (<RL>) { chomp; next if /^$/; my ($fn, $rl, $mle, $rce, $mlfn, $mlln, $mlac, $mlpn, $ml2e, $ml2fn, $ml2ln, $ml2pn, $retname, $ml2ac, $rc2e, $fc, $retid, $scrname, $exec, $freq, $fnum) = split /:/; if ($fnum eq ""){ my $fnum = "_001"; } %rets = ( ${retid}.${fnum} => { FNAME => $fn, RECLEN => $rl, LIAISON_EMAIL => $mle, LIAISON_FNAME => $mlfn, LIAISON_LNAME => $mlln, LIAISON_AREACODE => $mlac, LIAISON_PHONE => $mlpn, LIAISON2_EMAIL => $ml2e, LIAISON2_FNAME => $ml2fn, LIAISON2_LNAME => $ml2ln, LIAISON2_PHONE => $ml2pn, RETNAME => $retname, RETAILER_EMAIL => $rce, LIAISON2_AREACODE => $ml2ac, RETAILER2_EMAIL => $rc2e, FTPCHECK => $fc, RETID => $retid, SCRIPT_NAME => $scrname, EXECFLAG => $exec, FREQUENCY => $freq, FILE_NUMBER => $fnum } ); } close RL; foreach my $id (keys %rets) { print "$id\n"; }

when I execute this I get no errors. However I only have one record in %rets. I thought I would have had a separate reference to each %rets=>$retid.$fnum
I'm very confused. I do tink I'm close but I still need help!


In reply to Hash of anonymous hashes --- Oh my by sweetblood

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.