I have a Perl program that gets the date of a file using 'ctime' from "use
Time::localtime;" But this program must also convert an
Epoch time to a date and time using 'localtime'
from "use Time::Local;". The
problem is it appears that only one of these modules can be used in a
single program. Not both since a localtime
subroutine exist as the same name in both modules. How can I support
using both modules in the same program?. Here are the snippits: #!/usr/bin/perl use Time:localtime; use Time:Local; #needs Time::Local........ sub convertEPOCHtime ($) { my $time = $_[0]; my ($seconds, $minutes, $hours, $day_of_month, $month, $year, $wday, $yday, $isdst) = localtime ($time); $year += 1900; my @themonths = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"); my @weekdays = ("xxx", "Sat", "Sun", "Mon", "Tue", "Wed", "Thr", "Fri", ); if ($hours < 10) { $hours = '0' . "$hours"; } my $datestring = "$weekdays[$wday] $themonths[$month] $day_of_month ${hours}:${minutes} $year"; return ($datestring); } # needs Time::localtime........ sub FILEdate ($) { my $filename = $_[0]; my $as_of_date = ctime(stat("$filename")->mtime); return ($as_of_date); } --
|
- Conflict with Time::Local and Time::localtime Michael Barto
- Re: Conflict with Time::Local and Time::localtime Sherm Pendley