Re: Explaining why to use $array[0] instead of @array[0]

[email protected] (Jacinta Richardson) Wed, 22 Oct 2008 11:23:37 +1100
Newsgroups perl.trainers
Organization Perl Training Australia Pty Ltd
Message-ID <[email protected]>
DavidB wrote:

> I'm talking demonstrable reason, not any "just because it's proper"
> reasons like 1 and 2 above.  I can talk their ears off telling them
> it's the right thing to do, but I'd prefer to have some practical
> reason.

We provide some of these in our Perl Tip: Common problems with slices
http://perltraining.com.au/tips/2005-09-05.html

Some examples from that tip:

	@data[1] = <STDIN>;             # Almost certainly a mistake

	my @array = ( 'a' .. 'e' );
        @array[@array] = 'f';           # Does not generate a warning!

All the best,

	J


-- 
   ("`-''-/").___..--''"`-._          |  Jacinta Richardson         |
    `6_ 6  )   `-.  (     ).`-.__.`)  |  Perl Training Australia    |
    (_Y_.)'  ._   )  `._ `. ``-..-'   |      +61 3 9354 6001        |
  _..`--'_..-_/  /--'_.' ,'           | [email protected] |
 (il),-''  (li),'  ((!.-'             |   www.perltraining.com.au   |