1753979 Members
4091 Online
108811 Solutions
New Discussion юеВ

Perl Scripting Again

 
SOLVED
Go to solution
Shannon Petry
Honored Contributor

Perl Scripting Again

Okay, it does not work. I syntaxed it as perscribed....

use Time::Local;
$TIME = timelocal($sec, $min, $hours, $mday, $mon, $year);

print $time;

%> perl test.pl
Day '' out of range 1..31 at test.pl line 2
%> more test.pl
use Time::Local;
$TIME = timelocal($sec,$mim,$hour,$mday,$mon,$year);
print ($TIME);

Using the other suggestion of POSIX
I.E.
use POSIX;
$TIME = POSIX::strftime('%y%m%d',localtime(time));
works though.

It does not really mater to me how I get the time, it is for read only so I dont need to modify. The last question then is their any problems with security and CGI adding "use POSIX" to the script?

Thanks for the help
Microsoft. When do you want a virus today?
3 REPLIES 3
John Bolene
Honored Contributor

Re: Perl Scripting Again

Shows me to run it before I make it public.

Try this

use Time::Local;
($sec, $min, $hours, $mday, $mon, $year) = localtime;
$year = $year + 1900;

I had the function backwards.

$year is the years past 1900, so have to add 1900 to it.
It is always a good day when you are launching rockets! http://tripolioklahoma.org, Mostly Missiles http://mostlymissiles.com
Frederic Soriano
Honored Contributor
Solution

Re: Perl Scripting Again

Hi Shannon,

As POSIX is a standard module distributed with perl core, I do not think there is any security problem here.

To limit use of POSIX module, instead of

use POSIX

you can say:

use POSIX qw(:time_h)

which will include only functions related to time_h (like strftime), rather than the whole POSIX stuff.

HTH !

Best regards.

Fred.
Shannon Petry
Honored Contributor

Re: Perl Scripting Again

Thanks for the help. The POSIX works well enough that
I'll stick with it for now. Still I'll play around with the other format.

Just wish one of my 2 O'Reilly books had date functions!
Hmmmmmm.....

Regards,
Shannon
Microsoft. When do you want a virus today?