[Za-pm] Re: perldoc

Nick Cleaton nick at cleaton.net
Fri Jun 6 04:41:45 CDT 2003


On Fri, Jun 06, 2003 at 10:55:21AM +0200, Sean Carte wrote:
> On Fri, 2003-06-06 at 10:15, Nick Cleaton wrote:
> > exec 'perldoc', $0 if "@ARGV" eq '--help';
> 
> Aha! I'm using $ARGV[0] where you're using @ARGV:

That'll do it :)

> Your version uses the @ARGV array in a scalar context. Does this mean
> that @ARGV evaluates to $ARGV[0] before the comparison? If so, why is it
> different when specifying $ARGV[0]?

It's not @ARGV in a scalar context, it's @ARGV interpolated into a
doublequoted string.  When you interpolate an array into a string,
you get all the elements of the array joined with $", which is a
space by default.

For example:

  my @a = ('one', 'two');

  print "@a\n";  # prints "one two" 

If the array is empty, you just get the empty string rather than
undef.  That's why there's no warning with this method.

--
Nick



More information about the Za-pm mailing list