in reply to Last day of the month. Any shorter

You can save some characters and avoid some repetition by replacing the first line with
my ($y, $m, $d) = unpack('A4A2A2', $ARGV[0]);

Replies are listed 'Best First'.
Re: Re: Last day of the month. Any shorter
by Scarborough (Hermit) on May 19, 2004 at 13:38 UTC
    I'd like to if I understood what is happening here.
      unpack extracts values of various types from a string based on a format, in this case A4A2A2, and returns them as a list.
      A is a space padded sting of bytes, the number after it is the number of bytes in each value.
      So this format will return a string of the first 4 bytes (stripping away any trailing spaces if there were any) then the next 2 bytes and then the next 2 bytes.
      The end result is identical to the 3 calls to substr, but a bit more concise.