calling perl varibles in a shell script

Posted on 2009-04-21
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

    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

    More detail is needed.

    Here are two examples:

    Example 1

    system "/path/to/";

    echo $foo

    Example 2

    system "/path/to/ bar"

    echo "$1"
    LVL 84

    Expert Comment

    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


    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

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
    Recently, an awarded photographer, Selina De Maeyer (, completed a photo shoot of a beautiful event ( in An…
    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…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    746 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now