in reply to Faking Script Names

Your problem hinges on the idea that $0 in perl is like $ARGV[0] in C. The perl variable $0 is actually the name of the program that is running. The command line args are stored in @ARGV. So you really want $ARGV[0] (like in c). Try running this code:
use strict; use warnings; { print "\$0 = $0\n"; print "\$ARGV[0] = $ARGV[0]\n"; }
Assume that the name of this script is arg_test.pl, run the command:

>perl -w arg_test.pl foo

which yields this output:

$0 = arg_test.pl $ARGV[0] = foo
The rest of your scripts behaviour should become clear.

Replies are listed 'Best First'.
Re^2: Faking Script Names
by ikegami (Patriarch) on Jul 23, 2005 at 00:13 UTC
    I'm not sure what point is. For starters, $ARGV[0] corresponds to argv[1], not argv[0].
      As yes, my mistake, havent coded any C for many years.
      I use the most powerful debugger available: print!