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

Quinn Weaver quinn at fairpath.com
Fri May 11 14:33:58 PDT 2007


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.

One more thing:  you need to "export" your shell variables into the
environment in order for Perl to see them.  Otherwise the variables
are private to your shell.  For instance:

    DD=foo
    export DD
    perl -e 'use strict; use warnings; print "$ENV{DD}\n"';

That will output

    foo

But if you don't export...

    DD=foo
    perl -e 'use strict; use warnings; print "$ENV{DD}\n"';

You'll get this error message:

    Use of uninitialized value in concatenation (.) or string at -e line 1.

Because $ENV{DD} is undefined.

HTH.  When you move your Perl code to a separate file, remember to turn on

    use strict;
    use warnings;

-- 
Quinn Weaver, independent contractor  |  President, San Francisco Perl Mongers
http://fairpath.com/quinn/resume/     |  http://sf.pm.org/


More information about the SanFrancisco-pm mailing list