Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Call shell script variables in perl

by Eliya (Vicar)
on Mar 21, 2011 at 10:41 UTC ( #894466=note: print w/replies, xml ) Need Help??

in reply to Call shell script variables in perl

system runs a subprocess, and because a subprocess gets its own copy of the environment, you cannot set/modify an environment variable from within a subprocess such that it will be available to the parent process (your Perl script here).  In other words, the new subprocess' environment is gone as soon as the process has ended, i.e. when system returns.  Exporting won't help.

But you could print the variable's value to stdout in the shell script, and capture it in the Perl script (e.g. via backticks).

Replies are listed 'Best First'.
Re^2: Call shell script variables in perl
by k_manimuthu (Monk) on Mar 21, 2011 at 11:30 UTC

    Thanks for your information. I am showing (STDOUT) more information to the end user. I want to use the particualar variable only in my perl program. I will get the output as you metioned method and do regex stuff to to get the result. Thanks

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://894466]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2018-06-23 05:40 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (125 votes). Check out past polls.