qball has asked for the wisdom of the Perl Monks concerning the following question:

I'm running this shell script from a php script:
#!/bin/sh echo "GOT HERE = $MYFILENAME $COMPANYID $FROMDATE $TODATE" > /var/tmp/ +test.txt path/filename.pl $MYFILENAME $COMPANYID $FROMDATE $TODATE

I know the environment variables are being set b/c the output is in the test.txt file. When I try to capture the environment variables in perl, I'm not seeing them.
In the perl script I print $ARGV[0] and so forth, but get nothing in return.

qball~"I have node idea?!"

Replies are listed 'Best First'.
Re: Shell/Perl Variables
by VSarkiss (Monsignor) on Jun 28, 2001 at 01:02 UTC
    If you're always going to use the same environment variables, consider reading them directly in your Perl program rather than off the command line:
    my $filename = $ENV{MYFILENAME}; my $companyid = $ENV{COMPANYID};

    If you post the code you're using to process @ARGV, there may be a problem that someone here can spot and help with.


      Depending on whether the environment variables are exported or not, your suggestion might not work:

      % FOO=bar % echo $FOO bar % perl -le 'print shift' $FOO bar % perl -le 'print $ENV{FOO}' %

      g r i n d e r
        In the original example, the shell script was called from elsewhere, and the variables were setup outside of the shell. So, whether the shell exports variables or not is irrelevant.

        -- Abigail