in reply to exchanging data between shell script and perl -e

I suspect that this doesn't work because the "a" and "b" variables aren't in the environment. Try adding "export a;export b" in between the "b=" and "c=" lines.

Or you could just pass them on the command line:

c=`perl -e 'if ( $ARGV[0] < $ARGV[1]} ) { print "1\n"; } else { print +"0\"; }' $a $b`
Or, since you are using perl anyway, replace this toplevel shell script with a perl script, and open the pipes from perl.

Replies are listed 'Best First'.
Re: Re: exchanging data between shell script and perl -e
by Sinister (Friar) on Jul 25, 2001 at 16:40 UTC
    The export works just fine! Thank you!

    <update>
    setenv works even beter!
    </update>


    Sinister greetings.
    perldoc -q $_
      export and setenv are both doing the same thing: adding the variable to your environment, making them accessible to other processes running under the same environment.

      You use one or the other depending on what shell you are using. The Bourne shell, Korn Shell, bash etc. support 'export'. The C shell and its variants (tcsh etc.) support 'setenv'.

      I am not sure if any of the shells support both of them, though.