LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Perl datescript Issue, missing perl module? (http://www.linuxquestions.org/questions/programming-9/perl-datescript-issue-missing-perl-module-416293/)

stefaandk 02-16-2006 08:56 PM

Perl datescript Issue, missing perl module?
 
This is my perl script:

my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$s = sprintf("%02d%02d%02d", $mday, $mon+1, $year - 100);
print $s . "\n";


This should output a date, does it fine on one linux machine but on the other one I get:

./Datescript.pl: line 1: syntax error near unexpected token `$sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst'
./Datescript.pl: line 1: `my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);'

Anyone know which Perl module would accomodate this?

On the working system I have all these installed:

perl-Parse-Yapp-1.05-31
perl-XML-Dumper-0.71-1
perl-Time-HiRes-1.55-2
perl-FreezeThaw-0.43-61psa
perl-Font-AFM-1.18-61psa
perl-IO-Zlib-1.01-fc2.build75050824.12
perl-5.8.3-18
perl-DateManip-5.42a-1
perl-HTML-Parser-3.35-5
perl-libwww-perl-5.79-1
perl-libxml-perl-0.07-29
perl-XML-Encoding-1.01-25
perl-Digest-SHA1-2.07-4
perl-DBD-MySQL-2.9003-4
perl-Net-DNS-0.45-3
perl-Compress-Zlib-1.33-4
perl-HTML-Tree-3.16-fc2.build75050824.12
perl-MLDBM-2.01-61psa
perl-HTML-Format-1.23-51psa
perl-Text-Iconv-1.2-22
perl-IO-Ftp-0.05-fc2.build75050824.12
perl-Filter-1.30-5
perl-URI-1.30-1
perl-HTML-Tagset-3.03-29
perl-XML-Parser-2.34-2
perl-libxml-enno-1.02-30
perl-DBI-1.40-4
mod_perl-1.99_12-2.1
perl-Digest-HMAC-1.01-12
perl-TimeDate-1.16-1
perl-MLDBM-Sync-0.30-61psa
perl-MIME-Lite-2.117-fc2.build75050824.12
perl-Apache-ASP-2.57-fc2.build75050824.12


On the target machine I have all these:

perl-Crypt-DES-2.03-3.1.fc3.rf
perl-Digest-HMAC-1.01-1.1.fc3.rf
perl-DateManip-5.42a-3
perl-DBI-1.40-5
perl-Filter-1.30-6
perl-Socket6-0.18-1.1.fc3.rf
perl-Digest-SHA1-2.10-1.1.fc3.rf
perl-Net-SNMP-5.0.1-1.1.fc3.rf
perl-TimeDate-1.16-2
perl-DBD-MySQL-2.9003-5
perl-URI-1.30-4
perl-5.8.5-12.FC3
perl-IO-Socket-INET6-2.51-1.1.fc3.rf
perl-Time-HiRes-1.55-3


So all time and date rpm's are there but still no go?

spooon 02-17-2006 10:29 PM

It works on my system, so I don't know what to tell you. How are you running it?

Rufus T. Firefly 02-18-2006 07:52 PM

You need ...
 
time::localtime

perldoc time::localtime <enter>

spooon 02-19-2006 04:12 AM

Quote:

Originally Posted by Rufus T. Firefly
time::localtime

perldoc time::localtime <enter>

No, that is the wrong thing. The OP is using Perl's built-in localtime() function (perldoc -f localtime) which returns a list of values, not something that generates some time object.

Harmaa Kettu 02-19-2006 03:51 PM

Obviously your script isn't correct bash syntax :rolleyes:. Add "#!/usr/bin/perl" to run it with perl instead.

stefaandk 02-19-2006 10:55 PM

Indeed, that did the trick, cheers!


All times are GMT -5. The time now is 12:00 AM.