Fellow monks,

I'm beginning to write a script to find older files and email the owners asking them to clean them up. Consider this snipped:

#using File::Find sub wanted{ #checks for old files if (-r && -f){ #get size of file (MB) $size=int((lstat($_))[7]/1000000); # check the age of file if ($opt{a} < -A && $size > $opt{s}){ #get user id $uid = (lstat($_))[4];

So now I have the uid, file name, file size and the file age. How do I store it? My though was to create a hash whose name is the uid. The keys (name, size, age) would reference an array for file name, size and age. Now I have these questions:

  1. Is is safe to use a variable variable name for the hash (%$uid)? If so what is the correct syntax?
  2. What is the syntax to push the values into the array referenced by the hash?
  3. Would you do it another way?

Thanks for your time.

Neil Watson
watson-wilson.ca


In reply to Help with complex data structures by neilwatson

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.