Operating System - HP-UX
1833247 Members
2970 Online
110051 Solutions
New Discussion

error message :::syntax error in file , next 2 tokens 'use time'..pls help as i am new to Perl

 
viral
Occasional Contributor

error message :::syntax error in file , next 2 tokens 'use time'..pls help as i am new to Perl

i am trying to execute this piece of code and its giving errors:
is it something to do with the version of perl or some syntax.......
pls help as i am quite novice to perl...

use Time::Local;
my %months=qw(Jan 0 Feb 1 Mar 2 Apr 3 May 4 Jun 5 Jul 6 Aug 7 Sep 8 Oct 9 Nov 10 Dec 11);
my %days=qw(Sun 0 Mon 1 Tue 2 Wed 3 Thu 4 Fri 5 Sat 6);

my ($hour,$min,$sec)=split ':',$ARGV[3];
my $day=$days{$ARGV[0]};
my $month=$months{$ARGV[1]};
my $mday=$ARGV[2];
my $year=$ARGV[4]-1900;

my $time=timelocal($sec,$min,$hour,$mday,$month,$year);
print "$time\n";
1 REPLY 1
harry d brown jr
Honored Contributor

Re: error message :::syntax error in file , next 2 tokens 'use time'..pls help as i am new to Perl


You mean localtime and not timelocal, right?

Do you have a

#!/usr/bin/perl

or something like it, as the first line?

See this: http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=56594
or
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=191484

What are you inputing into the script?


live free or die
harry d brown jr
Live Free or Die