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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
02-16-2006, 09:56 PM
|
#1
|
Member
Registered: Jun 2005
Distribution: Centos
Posts: 215
Rep:
|
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?
|
|
|
02-17-2006, 11:29 PM
|
#2
|
Senior Member
Registered: Aug 2005
Posts: 1,755
Rep:
|
It works on my system, so I don't know what to tell you. How are you running it?
|
|
|
02-18-2006, 08:52 PM
|
#3
|
LQ Newbie
Registered: Feb 2006
Location: Hermosa CA
Distribution: Fedora
Posts: 8
Rep:
|
You need ...
time::localtime
perldoc time::localtime <enter>
|
|
|
02-19-2006, 05:12 AM
|
#4
|
Senior Member
Registered: Aug 2005
Posts: 1,755
Rep:
|
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.
|
|
|
02-19-2006, 04:51 PM
|
#5
|
Member
Registered: Apr 2005
Location: Finland
Posts: 196
Rep:
|
Obviously your script isn't correct bash syntax  . Add "#!/usr/bin/perl" to run it with perl instead.
|
|
|
02-19-2006, 11:55 PM
|
#6
|
Member
Registered: Jun 2005
Distribution: Centos
Posts: 215
Original Poster
Rep:
|
Indeed, that did the trick, cheers!
|
|
|
All times are GMT -5. The time now is 10:57 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|