So I'm looking to create a definable timestamp from the value of localtime and I realised I needed to zero pad several values to make the timestamps numerically sortable. My first attempt was
my($sec,$min,$hour,$day,$month,$year,$wday,$yday,$isdst) = localtime(t +ime); $year += 1900; $month++; my @pad = qw (sec min hour day month); for (@pad) { $$_ = zeropad($$_); }
I went to run it and as usual perl is telling me it can't do something we both know it can. Tried other ways of dereferencing that should work like ${$_} and no dice. Wasted the next 20 minutes searching and like most internet searches relating to Perl all I can find is pages of long-winded, unasked for answers explaining that is bad and should never be done and and almost nothing in regards to if it can be done. What scant information I can find suggests it's possible only on global variables and only after I've turned of strict referencing which actually sounds really bad but only due to Perl sucking at variables rather than my solution. I'll probably use a hash but just once it would be nice to write some elegant code instead of having to refactor or kludge around autocracy.

In reply to What's so wrong with this (dereferencing)code? by Maelstrom

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.