calling perl varibles in a shell script


How can we call perl variables in a shell script? Can somebody give an example?

Who is Participating?
Adam314Connect With a Mentor Commented:
Do you mean access them?  Directly, you can't.
You can have perl access the shell's environment variables, through the %ENV variable.

You could have perl output the value of it's variables, and the shell could read those.  What are you trying to do?
More detail is needed.

Here are two examples:

Example 1

system "/path/to/";

echo $foo

Example 2

system "/path/to/ bar"

echo "$1"
by "call" do you mean
name, or say, or invoke, or command, or signal, or predict, or summon, or designate, or need, or postpone,  announce, or ... ?
which perl variables do you want to call?  in what perl program?
is the shell process a parent of the perl process?
is the perl process a parent of the shell process?
Do they run on the same machine?
Do they run at the same time?
Are you writing a perl script that needs to work with an existing shell script?
are you writing a shell script that needs to work with an existing perl scipt?
what would these shell and perl scripts do?

echo "This is a basic bash shell script"
echo ""
echo "This is a Perl string within the bash script:"
echo ""
perl -e 'for(1..10) {print "$_\n";}'
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.