in reply to pass perl variable to shell script

You could write your variables into a file and evaluate the file afterwards.

Or if you don't need the stdout of your program for an other purpose, write to stdout the value of the variable in the syntax of shell assignment, and use "eval" on the output of your Perl program, i.e. something like

eval `perl .....`

-- 
Ronald Fischer <ynnor@mm.st>

Replies are listed 'Best First'.
Re^2: pass perl variable to shell script
by arthurs (Novice) on Aug 11, 2010 at 15:09 UTC
    Thank you rovf. Yes, I can write the variable into a file, but this sounds complex. I am looking for a simpler solution like your suggestion to right into stdout. Could you elaborate on your answer? Why would I eval it on the output of the perl if I need to access it in the shell. I thought maybe to write to a stdout in the perl, and then somehow get it in the shell. A code snippet would be helpful. Thanks much.

      #!/bin/sh eval `perl -we "print FOO=BAR"` echo $FOO

      -- 
      Ronald Fischer <ynnor@mm.st>