Ok, a few things:
1: Lists are contained in parentheses, and array literal references are written between the brackets. So you should have:
my @holidays = ([2012,'01','02'],[2012,'01','16'],[2012,'02','20'],[2012,'04','16'],[2012,'05','28'], [2012,'07','04'],[2012,'09','03'],[2012,'10','08'],[2012,'11','12'],[2012,'11','22'],[2012,'12','25']);
2: When you watch $holidays[@dueDate]
, you call everything in a scalar context . In particular, since @dueDate
has three elements, you only look at $holidays[3]
.
3: If you are not writing a piece of code, always use strict;
and use warnings;
.
So you want something like this:
use strict; use warnings; my @holidays = ([2012,'01','02'],[2012,'01','16'],[2012,'02','20'],[2012,'04','16'],[2012,'05','28'], [2012,'07','04'],[2012,'09','03'],[2012,'10','08'],[2012,'11','12'],[2012,'11','22'],[2012,'12','25']); my @dueDates=([2012,'01','01'],[2012,'01','02'],[2012,'01','03']);
The above code outputs the following result:
2012-01-02