[sf-perl] Embedded Perl in a Korn shell program

Loo, Peter # PHX Peter.Loo at source.wolterskluwer.com
Fri May 11 15:01:16 PDT 2007


Thanks Adam.  I am afraid I don't have the luxury of using "date"
utility in my Sun Unix OS.  :D
 
date: illegal option -- d
usage:  date [-u] mmddHHMM[[cc]yy][.SS]
        date [-u] [+format]
        date -a [-]sss[.fff]
 
Peter

________________________________

From: sanfrancisco-pm-bounces+peter.loo=source.wolterskluwer.com at pm.org
[mailto:sanfrancisco-pm-bounces+peter.loo=source.wolterskluwer.com at pm.or
g] On Behalf Of Adam Morgan
Sent: Friday, May 11, 2007 2:41 PM
To: San Francisco Perl Mongers User Group
Subject: Re: [sf-perl] Embedded Perl in a Korn shell program


As well as all the good advice you have already received, if you are
using the perl purely to add a day to the date in ksh, then you can get
that fiunctionality using the gnu date command, for example:
 
date -d "01/01/2002 +1 day"
gives  "Wed Jan  2 00:00:00 MST 2002" as it's result

or
 
date -d "+1 day"
gave "Sat May 12 15:39:09 MDT 2007" when I ran it as it is relative to
now.

________________________________

From: sanfrancisco-pm-bounces+adam.morgan=safeway.com at pm.org
[mailto:sanfrancisco-pm-bounces+adam.morgan=safeway.com at pm.org] On
Behalf Of Loo, Peter # PHX
Sent: Friday, May 11, 2007 2:10 PM
To: sanfrancisco-pm at pm.org
Subject: [sf-perl] Embedded Perl in a Korn shell program


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

This E-mail message is for the sole use of the intended recipient(s) and
may contain confidential and privileged information. Any unauthorized
review, use, disclosure or distribution is prohibited. If you are not
the intended recipient, please contact the sender by reply E-mail, and
destroy all copies of the original message. 

"MMS <safeway.com>" made the following annotations.
------------------------------------------------------------------------
------
Warning: 
All e-mail sent to this address will be received by the Safeway
corporate e-mail system, and is subject to archival and review by
someone other than the recipient. This e-mail may contain information
proprietary to Safeway and is intended only for the use of the intended
recipient(s). If the reader of this message is not the intended
recipient(s), you are notified that you have received this message in
error and that any review, dissemination, distribution or copying of
this message is strictly prohibited. If you have received this message
in error, please notify the sender immediately. 

========================================================================
======


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/sanfrancisco-pm/attachments/20070511/d1c3b58a/attachment.html 


More information about the SanFrancisco-pm mailing list