Gossamer Forum
Home : Products : Others : Fileman :

really great feature

Quote Reply
really great feature
I was wondering if someone could help me out with deciphering which aspect of the script dynamically creates the date that the folders were last modified on? I'd like to do this with other scripts - but I'm new to perl. Any help is appreciated.
thanks in advance
Mike
Quote Reply
Re: really great feature In reply to
The subroutine is as shown below:

sub get_date {
# --------------------------------------------------------
my $time = shift;
$time or ($time = time);
my @months = qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!;

my ($min, $hr, $day, $mon, $yr) = (localtime($time))[1,2,3,4,5];
$yr = $yr + 1900;
($min < 10) and ($min = "0$min");
($hr < 10) and ($hr = "0$hr");
($day < 10) and ($day = "0$day");

return "$day-$months[$mon]-$yr $hr:$min";
}

The most important subroutine that Perl uses
for telling the time is:
(localtime($time))[1,2,3,4,5]

where
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime();

so localtime($time)[1] would be $min which stands for minute
and localtime($time)[2] would be $hour which stands for hour and so on

Hope that helps
Sun

------------------
-------------------- Gossamer Threads Inc. ----------------------
Sun Djaja Email: sun@gossamer-threads.com
Internet Consultant
http://www.gossamer-threads.com