[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


calling perl varibles in a shell script

Posted on 2009-04-21
Medium Priority
Last Modified: 2013-12-26

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

Question by:AyooshJ
LVL 39

Accepted Solution

Adam314 earned 150 total points
ID: 24196420
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?
LVL 48

Expert Comment

ID: 24199760
More detail is needed.

Here are two examples:

Example 1

system "/path/to/script.sh";

echo $foo

Example 2

system "/path/to/script.sh bar"

echo "$1"
LVL 85

Expert Comment

ID: 24200227
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?
LVL 11

Expert Comment

ID: 24214806

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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses
Course of the Month19 days, 5 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question