in reply to return values with system()

When I run the application locally it sets the environment variable $status to 4. .... system($cmd;echo $status);
Have you tried that? AFAIK you can't "push" environment variables to the parent process (in this case the shell) on UNIX - i.e. if you set an env variable it will only affect the current process and it's children.

I would probably just print out the value to STDOUT and retrieve it in the perl process using backquotes. Setting variables and then echo()ing them is useless overhead.

my $output = `some-program`; print "Output from some-program is '$output'";
that way you're much more flexible and it's easier to debug since you can immediately see the output if you run the program on its own.

Replies are listed 'Best First'.
Re^2: return values with system()
by jason (Initiate) on Feb 13, 2007 at 19:03 UTC
    Thanks. This is what I'll do.