[sf-perl] Embedded Perl in a Korn shell program
Loo, Peter # PHX
Peter.Loo at source.wolterskluwer.com
Fri May 11 14:10:22 PDT 2007
Hi All,
I am trying to add a day to a date using Perl Time::Local library within
a Korn shell. However it is not allowing my Korn shell variable to be
used within the Perl command.
MM=05
DD=06
YYYY=2007
DAY_ADDED=`perl -e 'use Time::Local; ($secs =
timelocal(0,0,0,$MM,$DD,$YYYY) + 86400); ($year, $mon, $day) =
(localtime($secs))[5,4,3]; $year+=1900; $mon =~ s/^/0/ if $mon < 10;
$day =~ s/^/0/ if $day < 10; print $year . $mon . $day;';`
echo $DAY_ADDED
I am getting the following error:
Day '' out of range 1..31 at -e line 1
Then I tried the following and got a different error:
PERL_CMD="perl -e 'use Time::Local; (\$secs =
timelocal(0,0,0,$MM,$DD,$YYYY) + 86400); (\$year, \$mon, \$day) =
(localtime(\$secs))[5,4,3]; \$year+=1900; \$mon =~ s/^/0/ if \$mon < 10;
\$day =~ s/^/0/ if \$day < 10; print \$year . \$mon . \$day; ';"
DAY_ADDED=`${PERL_CMD}`
Can't find string terminator "'" anywhere before EOF at -e line 1.
What am I doing wrong here?
Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/sanfrancisco-pm/attachments/20070511/7d3f90cb/attachment.html
More information about the SanFrancisco-pm
mailing list