[Pdx-pm] evil @ARGV syntax

Michael G Schwern schwern at pobox.com
Wed Jul 20 11:30:33 PDT 2005

On Wed, Jul 20, 2005 at 05:47:01AM -0700, Michael Rasmussen wrote:
> For a topic that confuses new Perl folk this would seem to be something
> that should be covered at every available opportunity.  The section on
> @ARGV does cover the $# issue:

That's thrown in there, in a somewhat obtuse way, to help C programmers 
where ARGV[0] is the command name and ARGV[1] is the first argument.

> Which would be a GoodThing considering the trouble that people have 
> with the issue.

Yes, and while we're at it since @ARGV is global don't forget to talk about
how to localize it!  And because its an array be sure to explain that arrays 
start at 0 and what an index of -1 means.   And be sure to talk about the
difference between an array and a list, people get that confused a lot.
And @ARGV can be popped and pushed and spliced and sliced and shifted and
unshifted so be sure to bring those up.

Oh, and repeat those docs for every other array in perlvar.  @INC and
@+ and @_ and @- and @F.  And then we start in on scalars.

At some point you have to assume the reader has read the introductory texts
otherwise you wind up clogging the docs with repeated tutorial documentation
making it like reading through a legal document with all the repeated, 
verbose prose.

	The Company reserves the right to all inventions, works, plans,
	patents, descriptions and thoughts of the Employee.  The Employee
	waives all rights to all inventions, works, plans, patents,
	descriptions and thoughts.  Should any inventions, works, plans,
	patents, descriptions and thoughts be found illegal in any...

It would be nice if the documentation could be annotated with unobtrusive
references to other parts of the docs sprinkled liberally throughout but
POD doens't support that sort of thing very well.

[1] This one we probably should.

Michael G Schwern     schwern at pobox.com     http://www.pobox.com/~schwern
Ahh email, my old friend.  Do you know that revenge is a dish that is best 
served cold?  And it is very cold on the Internet!

More information about the Pdx-pm-list mailing list