title: Perl: Can't pass an "on-the-fly" array to a sub
body: <p>strftime(), as per cpan.org:</p>
  
  <pre><code>print strftime($template, @lt);
  </code></pre>
  
  <p>I just can't figure the right Perl code recipe for this one. It keeps reporting an error where I call strftime():</p>
  
  <pre><code>...
  use Date::Format;
  ...
  sub parse_date {
   if ($_[0]) {
    $_[0] =~ /(\d{4})/;
    my $y = $1;
    $_[0] =~ s/\d{4}//;
    $_[0] =~ /(\d\d)\D(\d\d)/;
    return [$2,$1,$y];
    }
   return [7,7,2010];
   }
  
  foreach my $groupnode ($groupnodes-&gt;get_nodelist) {
      my $groupname = $xp-&gt;find('name/text()', $groupnode);
      my $entrynodes = $xp-&gt;find('entry', $groupnode);
      for my $entrynode ($entrynodes-&gt;get_nodelist) {
          ...
          my $date_added = parse_date($xp-&gt;find('date_added/text()', $entrynode));
          ...
          $groups{$groupname}{$entryname} = {...,'date_added'=&gt;$date_added,...};
          ...
          }
      }
  ...
  
  my $imday = $maxmonth &lt;= 12 ? 0 : 1;
  ...
  
  while (my ($groupname, $entries) = each %groups) {
      ...
      while (my ($entryname, $details) = each %$entries) {
          ...
          my $d = @{$details-&gt;{'date_added'}};
          $writer-&gt;dataElement("creation", strftime($date_template, (0,0,12,@$d[0^$imday],@$d[1^$imday]-1,@$d[2],0,0,0)));
          }
      ...
      }
  ...
  </code></pre>
  
  <p>If I use () to pass the required array by strftime(), I get:
  Type of arg 2 to Date::Format::strftime must be array (not list) at ./blah.pl line 87, near "))"</p>
  
  <p>If I use [] to pass the required array, I get:
  Type of arg 2 to Date::Format::strftime must be array (not anonymous list ([])) at ./blah.pl line 87, near "])"</p>
  
  <p>How can I pass an array on the fly to a sub in Perl? This can easily be done with PHP, Python, JS, etc. But I just can't figure it with Perl.</p>
  
  <p><strong>EDIT: I reduced the code to these few lines, and I still got the exact same problem:</strong></p>
  
  <pre><code>#!/usr/bin/perl
  
  use warnings;
  use strict;
  use Date::Format;
  
  my @d = [7,13,2010];
  my $imday = 1;
  print strftime( q"%Y-%m-%dT12:00:00", (0,0,12,$d[0^$imday],$d[1^$imday]-1,$d[2],0,0,0));
  </code></pre>