Hello, I've got a subroutine that produces a nested hash, as below:
sub build_quota_list { my %users; open QUOTA, $quotareport; while (<QUOTA>) { if (m/ \+[ \-]/) { my ($username, $over, $used, $soft_block, $hard_block, $junk) +=split " ", $_, 6; $users{$username}{uname}=$username; $users{$username}{used}=$used; $users{$username}{soft_block}=$soft_block; $users{$username}{hard_block}=$hard_block; } } close QUOTA; return %users; }
I call it like this: my %users=build_quota_list; It seems to work fine; I've verified with the debugger that my nested hash contains what I expect it to contain. However, when I try to pass that selfsame has into a subroutine, all hell breaks loose.
sub find_deletion_candidates { my %users=@_; use User::pwent; foreach(keys %users) { my %user=$_; my $pw=getpwnam($user{uname}); my $homedir=$pw->dir; } # do bunch o' stuff I haven't coded yet return %users; } %users=find_deletion_candidates(%users);

It's really wierd. With the debugger (ptkdb), I can verify that @_ looks like I'd expect, my nice nested hash. But after I do my %users=@_, %users doesn't contain what I expect. What am I doing wrong?

Thanks a ton,

Aaron

In reply to hash parameter question by PerlHeathen

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.