in reply to passing a variable from shell script to the main perl
Each process has its own environment. A process gets its environment from its parent. Changing the shell's environment in no way affects perl's. The only possible processes it can affect are children of the shell, and only those that are created after the change takes place.
If you want to send data to a parent process, it's commonly done via a pipe connected to the child's STDOUT.
$ perl -e'print "Got: ", `sh -c "echo foo"`;' Got: foo
|
|---|