Operating System - HP-UX
1845948 Members
2476 Online
110250 Solutions
New Discussion

Re: Problem with perl command

 
Lukasz_6
Occasional Advisor

Problem with perl command

Hi,

does anybody know why this command works fine on hp-ux 11.11 bur doesn't work on hp-ux 11.00:
--------------------------------------------
perl -e 'print scalar localtime(time-86400)'
--------------------------------------------
on both nodes I have perl 5.8.0_B0.
6 REPLIES 6
harry d brown jr
Honored Contributor

Re: Problem with perl command

What is the error message?

Check to make sure each is running the same perl:

which perl

live free or die
harry d brown jr
Live Free or Die
Lukasz_6
Occasional Advisor

Re: Problem with perl command

From node where everything works fine:
------------------------------------------
$ perl -e 'print scalar localtime(time-86400)'
Mon May 30 14:10:12 2005
$
------------------------------------------

and the second one, where function scalar doesn't work:
------------------------------------------
$ perl -e 'print scalar localtime(time-86400)'
$
------------------------------------------
as you see there is no error.

When I am using this commacnd without func. scalar it works fine on both nodes.:

-------------------------------------------
$ perl -e 'print localtime(time-86400)'
35121430410511491
$
-------------------------------------------

both nodes uses the same path:
/usr/contrib/bin/perl
H.Merijn Brand (procura
Honored Contributor

Re: Problem with perl command

I bet it's a $PATH problem. The scalar syntax not being supported in perl4 makes me thing you are using an ancient version of perl

a5:/u/usr/merijn 38 > perl -le 'print localtime(time-86400)'
49181430410511491
a5:/u/usr/merijn 39 > perl -le 'print scalar localtime(time-86400)'
Mon May 30 14:18:52 2005
a5:/u/usr/merijn 40 > perl4 -le 'print localtime(time-86400)'
58181430410511491
a5:/u/usr/merijn 41 > perl4 -le 'print scalar localtime(time-86400)'

a5:/u/usr/merijn 42 >

If you'd have used -w, a rather obscure message could have pointed you there

a5:/u/usr/merijn 42 > perl4 -wle 'print scalar localtime(time-86400)'
Use of uninitialized variable at /tmp/perl-ea28878 line 1.

a5:/u/usr/merijn 43 >

Check your version with

# perl -v

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
harry d brown jr
Honored Contributor

Re: Problem with perl command

Yup, again check your perl paths:

which perl

live free or die
harry d brown jr
Live Free or Die
Gopi Sekar
Honored Contributor

Re: Problem with perl command


localtime function uses strftime and ctime to get time values.

try using Time::Local and see whether it works for you.

Regards,
Gopi
Never Never Never Giveup
Lukasz_6
Occasional Advisor

Re: Problem with perl command

Thanks you all folks,
the problem was with wrong path to perl - swlist show perl 5.8.0_B0 in /opt/perl/5.8.0
but which perl shows /usr/contrib/bin/perl.
When I used direct path /opt/perl/5.8.0/bin/perl it works fine on both nodes.