Argv 0, $0, and $^X

A

Alan Barclay

Using perl5.005 this script outputs 'zero'

#!/usr/bin/perl

exec {'/usr/bin/perl'} ('zero','-e','print $^X,"\n"');

Using 5.8.0 the same script gives /usr/bin/perl - the actual path of
perl.

Perlvar says

$^X The name used to execute the current copy of Perl, from
C's
"argv[0]".

But this isn't argv[0], because I forced argv[0] to be zero in my
script.

This is obviously a behaviour change somewhere between 5.005 and
5.8.0, and I can see how in some ways that 5.8.0 behaviour is more
useful, but there is definatly a conflict between the documented
behaviour and the actual behaviour. Which one is right?
 

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

No members online now.

Forum statistics

Threads
474,141
Messages
2,570,818
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top