How to fix this code

I have the following code:
$record{'Date'}="992364126";

I call a sub routine:
require "translate_date_time.pl";
($shmonths,$r_in->{'date_order'}) = translate_date_time(); # Read date/time

This subroutine look something like this:
-------------------------------------------------------
@shmonths = qw(Jan Feb Mar Apr May Jun Jul Aug Sept Oct Nov Dec);
$date="mon,22-01-69";

return (\@shmonths,$date);
-------------------------------------------------------

My main script looks then:

my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime($record{'Date'});

print "$shmonths[$mon]";

For example when the $mon = 11, the $shmonths[$mon] has to be "Dec". But tht isn't.
What am I doing wrong??
netjeAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
marecsConnect With a Mentor Commented:
$shmonths is a reference to an array. @shmonths does not exist, therefore $shmonths[$mon] refers to element $mon in @shmonths which does not exist. What you want is

print "$shmonths->[$mon]";
0
 
shlomoyCommented:
arrays start with index 0 and not 1...
0
 
netjeAuthor Commented:
Sorry what do you mean.
I know that arrays start with 0.
Therefor $shmonths[11] has to "Dec" and not "Nov".
But that is not the problem!!
I get nothing as a result??
0
 
shlomoyCommented:
That's ok.

11 is Nov (the 11th month)
12 is Dec.

$mon is a number from 1 to 12.

That's ok.

0
 
shlomoyCommented:
$$shmonths[$mon]
should work as well.
0
All Courses

From novice to tech pro — start learning today.