Conflict with Time::Local and Time::localtime

2006-12-31 Thread Michael Barto




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);
}

-- 





  

  
  


  Michael Barto
  Software Architect
  
  
  
  


   LogiQwest
Inc.
16458 Bolsa Chica Street, # 15
Huntington Beach, CA  92649
  http://www.logiqwest.com/
  
  
     
  [EMAIL PROTECTED]
Tel:  714 377 3705
Fax: 714 840 3937
Cell: 714 883 1949
  
  


  'tis a gift to be
simple
   


   This e-mail may contain
LogiQwest
proprietary information and should be treated as confidential. 

  








Re: Conflict with Time::Local and Time::localtime

2006-12-31 Thread Sherm Pendley

On Dec 31, 2006, at 4:19 AM, Michael Barto wrote:

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;


You're importing everything by default. Instead, only import the  
specific functions you need from each module:


#!/usr/bin/perl

use Time::localtime qw(ctime);
use Time::Local qw(localtime);

Have a look at "perldoc Exporter" for more, especially the section  
titled "How to Import".


sherm--

Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net