/ Published in: Perl

This is a script that simply prints the current month. I produced this a couple years ago and use it as a reference for using the localtime() function.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#!/usr/bin/perl use strict; use warnings; my ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime(); # You add 1 because the number in $month is based on a starting number of 0. # So, if $month is 0, then $monthnum is 1 (ie: January) # Adding 1 gets you a number from the list below. my $monthnum = $month + 1; my %monthname = ( 1 => 'January', 2 => 'February', 3 => 'March', 4 => 'April', 5 => 'May', 6 => 'June', 7 => 'July', 8 => 'August', 9 => 'September', 10 => 'October', 11 => 'November', 12 => 'December', );
Comments
