Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

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]
[Discipulus]: ma li mortacci sua!

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2017-11-24 07:50 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (345 votes). Check out past polls.