Unable to acces "$?" environment variable

  • Thread starter Yevgen Reznichenko
  • Start date
Y

Yevgen Reznichenko

Hello,

i want to use kdialog from my perl script. The return code of kdialog is
stored in the variable $?, but i an unable to access this:

my $result = $ENV{'\?'};
print "--> $result";

cause following warning:

Use of uninitialized value in concatenation (.) or string at
programs/mails_pop3.pl line 49, <FILE> line 1.
-->

if i print all available env variables, with:

foreach $key (sort(keys %ENV)) {
print "$key = $ENV{$key}\n";
}

so $? will not be listed. Do you know how i can get access to this variable?

Regards,

Yevgen
 
T

Tony Curtis

Hello, i want to use kdialog from my perl script. The
return code of kdialog is stored in the variable $?, but
i an unable to access this:
my $result = $ENV{'\?'}; print "--> $result";

$? is not an environment variable. It's a variable
maintained by various shells to record the exit behaviour
of sub-processes.

You want to fork into the command and then examine the
exit status of the child process.

perldoc -f system

shows you how.

hth
t
 
S

Steve Grazzini

Yevgen Reznichenko said:
i want to use kdialog from my perl script. The return code of
kdialog is stored in the variable $?, but i an unable to access
this:

my $result = $ENV{'\?'};
print "--> $result";

It's not an environment variable.

print "--> $?";

Check "perlvar" and the docs for system() or backticks or whatever
you were using to invoke kdialog.
 
Y

Yevgen Reznichenko

Am 01.11.2003 19:09 schrieb Steve Grazzini:
It's not an environment variable.

print "--> $?";

Many thanks, it works now fine.

Regards,

Yevgen
 
E

Eric J. Roode

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

i want to use kdialog from my perl script. The return code of kdialog
is stored in the variable $?, but i an unable to access this:

my $result = $ENV{'\?'};
print "--> $result";

Others have explained to you that $? is not an environment variable as
such, and therefore cannot be accessed via %ENV.

However: Why did you put a backslash before the question mark above?
That, combined with the single quotes, means you were trying to look up an
environment variable called \? -- two characters, a backslash and a
question mark.

- --
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP6QPC2PeouIeTNHoEQL3gACcCZSz2P+W+g0Oz4iHMjo56goGCIYAoII+
9S+tLbopxhUHTOd7c8JwMzr8
=QwPV
-----END PGP SIGNATURE-----
 
Y

Yevgen Reznichenko

Am 01.11.2003 20:52 schrieb Eric J. Roode:
my $result = $ENV{'\?'};
print "--> $result";
[...]
However: Why did you put a backslash before the question mark above?

It was an error, i was trying to escape "?" in the hope that it will
then works, but i doesn't and i forgot to delete them.

Regards,

Yevgen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top