calling perl varibles in a shell script

Hi

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

Thanks
AyooshJAsked:
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?
0
 
TintinCommented:
More detail is needed.

Here are two examples:

Example 1

#!/usr/bin/perl
$ENV{foo}='bar';
system "/path/to/script.sh";

#!/bin/sh
echo $foo

Example 2

#!/usr/bin/perl
system "/path/to/script.sh bar"

#!/bin/sh
echo "$1"
0
 
ozoCommented:
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?
0
 
kblack05Commented:
#!/bin/sh

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";}'
0
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.