LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 02-16-2006, 08:56 PM   #1
stefaandk
Member
 
Registered: Jun 2005
Distribution: Centos
Posts: 215

Rep: Reputation: 30
Question 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?
 
Old 02-17-2006, 10:29 PM   #2
spooon
Senior Member
 
Registered: Aug 2005
Posts: 1,755

Rep: Reputation: 48
It works on my system, so I don't know what to tell you. How are you running it?
 
Old 02-18-2006, 07:52 PM   #3
Rufus T. Firefly
LQ Newbie
 
Registered: Feb 2006
Location: Hermosa CA
Distribution: Fedora
Posts: 8

Rep: Reputation: 0
You need ...

time::localtime

perldoc time::localtime <enter>
 
Old 02-19-2006, 04:12 AM   #4
spooon
Senior Member
 
Registered: Aug 2005
Posts: 1,755

Rep: Reputation: 48
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.
 
Old 02-19-2006, 03:51 PM   #5
Harmaa Kettu
Member
 
Registered: Apr 2005
Location: Finland
Posts: 196

Rep: Reputation: 30
Obviously your script isn't correct bash syntax . Add "#!/usr/bin/perl" to run it with perl instead.
 
Old 02-19-2006, 10:55 PM   #6
stefaandk
Member
 
Registered: Jun 2005
Distribution: Centos
Posts: 215

Original Poster
Rep: Reputation: 30
Indeed, that did the trick, cheers!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl Module cant Install sohaib Red Hat 6 12-02-2005 09:22 AM
Problem with perl module for w3c validator to work on my local Apache+PHP+perl instal tbamt Linux - Software 0 12-16-2004 05:37 PM
perl gone missing rjilb Linux - Software 2 03-06-2004 11:08 PM
hosed perl - missing various perl headers suffer Slackware 4 11-14-2003 08:35 AM
perl(Cwd) perl(File::Basename) perl(File::Copy) perl(strict)....What are those? Baldorg Linux - Software 1 11-09-2003 08:09 PM


All times are GMT -5. The time now is 09:48 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration