Marshall has asked for the wisdom of the Perl Monks concerning the following question:

#usr/bin/perl -w use strict; use Data::Dumper; #core Perl module use Time::Local; #core Perl module #This "sort of works", but not completely my @valid_dates = #timegm( $sec, $min, $hour, $mday, $mon, $year ) [timegm (0,0,16,4,10, 2014), timegm (0,0,22,5,10,2014)], #2014 [timegm (0,0,16,5,10, 2013), timegm (0,0,22,6,10,2013)], #2013 [timegm (0,0,16,6,10, 2012), timegm (0,0,22,7,10,2012)], #2012 ; print Dumper \@valid_dates; __END__ prints: $VAR1 = [ [ 1415116800, 1415224800 ] ];

which I think is right as far as it goes. I want a array of arrays and this doesn't seem to do it. I am perplexed as to why the first line of the array def "works" and the rest do not?

There are no compile errors with this code.

I can think of other ways to accomplish the objective. The question is the easiest way to do this?

Update

Thanks! Sometimes these simple things are hard. /Marshall
my @valid_dates = #timegm( $sec, $min, $hour, $mday, $mon, $year ) ([timegm (0,0,16,4,10, 2014), timegm (0,0,22,5,10,2014)], #2014 [timegm (0,0,16,5,10, 2013), timegm (0,0,22,6,10,2013)], #2013 [timegm (0,0,16,6,10, 2012), timegm (0,0,22,7,10,2012)],)#2012 ;

Replies are listed 'Best First'.
Re: generating an array of array
by GrandFather (Saint) on Sep 16, 2014 at 04:18 UTC

    I strongly recommend you use use warnings which will give you some information about your problem even with a bollixed bang-splat line. Your first line should include a !, although if you are running on Windows that line is less important:

    #!usr/bin/perl -w

    With use warnings; (preferred technique) or the corrected bang-splat line above your script will generate something like:

    Useless use of anonymous list ([]) in void context at noname.pl line 1 +0. Useless use of anonymous list ([]) in void context at noname.pl line 1 +0.

    in addition to the $VAR1 dump.

    Perl is the programming world's equivalent of English
      I did bollix the she-bang line! No doubt about it. Under Windows, this doesn't matter. Under Unix, this matters a lot. The AofA works with formatting suggestions. I just screwed up with missing parens. Thanks, Marshall
Re: generating an array of array
by Cristoforo (Curate) on Sep 16, 2014 at 03:47 UTC
    You need to have your list enclosed with parenthesis.
Re: generating an array of array
by AnomalousMonk (Archbishop) on Sep 16, 2014 at 07:49 UTC

    Marshall: You appear to have deleted part or all of your OP. This is considered inconsiderate here in the Monastery. Please see How do I post a question effectively?, especially the second point under "And a few added points: ..."