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

Loo, Peter # PHX Peter.Loo at source.wolterskluwer.com
Fri May 11 14:31:23 PDT 2007


Thank you very much Quinn.  I had forgotten all about that.  Have a nice
weekend.
 
Peter

-----Original Message-----
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 Quinn Weaver
Sent: Friday, May 11, 2007 2:25 PM
To: San Francisco Perl Mongers User Group
Subject: Re: [sf-perl] Embedded Perl in a Korn shell program

On Fri, May 11, 2007 at 02:10:22PM -0700, Loo, Peter # PHX wrote:
> 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.

Right.  To get access to a shell variable within Perl, you need to
something like this:

    $ENV{DD}

%ENV is a magic tied hash that gives access to environment variables.

I think you would have an easier time with this program if you broke out
the Perl part into a separate file.  Then you could format it nicely,
instead of putting it all on one line.  Also, you could test it
separately.

I won't lecture you on the fact that this is an ugly hack, the kind that
gives Perl a bad name.  I assume you know that already. ;)

Also...

>  
> 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.

It's complaining that you are missing a closing single quote.  You did
perl -e '... and then never closed that quote.  Hairy quoting issues
like this are another good reason to move your Perl code to a separate
file.

--
Quinn Weaver, independent contractor  |  President, San Francisco Perl
Mongers
http://fairpath.com/quinn/resume/     |  http://sf.pm.org/
_______________________________________________
SanFrancisco-pm mailing list
SanFrancisco-pm at pm.org
http://mail.pm.org/mailman/listinfo/sanfrancisco-pm


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.


More information about the SanFrancisco-pm mailing list