Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi All Perl Gurus, I am a AIX/Linu

Status
Not open for further replies.

amritjsr

IS-IT--Management
Mar 4, 2008
12
JP
Hi All Perl Gurus,
I am a AIX/Linux Admin, I am writing a shell script where i m
using the following line ...

NDay=21;NMonth=06;NYear=12;NSec=15;NMin=30;NHour=12
perl -e ' use Time::Local; print scalar timelocal( $NSec, $NMin, $NHour, $NDay, $NMonth, $NYear)'

But it giving me error as below ....

Day '' out of range 1..31 at -e line 1

Any help will be very help full ... how to cope with this problem ...
 
Hi

If I understand your problem correctly, you are setting 6 shell variables then wondering why no Perl variable exist with the same names.

Either change the single quotes ( ' ) to double quotes ( " ) so the shell's variable expansion alter the Perl code before execution :
Code:
[blue]master #[/blue] NDay=21;NMonth=06;NYear=12;NSec=15;NMin=30;NHour=12

[blue]master #[/blue] perl -e "use Time::Local; print scalar timelocal $NSec, $NMin, $NHour, $NDay, $NMonth, $NYear"
1342863015

Or [tt]export[/tt] you variables and tell Perl that you are talking about environment variables :
Code:
[blue]master #[/blue] export NDay=21 NMonth=06 NYear=12 NSec=15 NMin=30 NHour=12

[blue]master #[/blue] perl -e 'use Time::Local; print scalar timelocal $ENV{NSec}, $ENV{NMin}, $ENV{NHour}, $ENV{NDay}, $ENV{NMonth}, $ENV{NYear}'
1342863015

Feherke.
[link feherke.github.com/][/url]
 
Hi Dear,
U r awesome dude ....
Thank U Soooo Much ....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top