How to use shell variables in perl command call in a bash shell script?

Variables from the shell are available in Perl’s %ENV hash. With bash (and some other shells) you need to take the extra step of “exporting” your shell variable so it is visible to subprocesses.

mydate=10/10/2012
export mydate
perl -e 'print "my date is $ENV{mydate}\n"'

Leave a Comment