I don't know that I'd agree with the assessment

        @ = ordered list
        % = unordered list

That's a bit confusing. It's true that a hash (or associative array) uses
its own sort order unless you use the 'sort' option.

But an array is a simple list of elements, whereas a hash is an associative
array, meaning each element (value) is associated with a unique key.

        @list = ('one','two','three','four');

        # scalar $list[1] gives you "two"


                   #key    #value
        %list = ('key0' => 'one',
                   'key1'       => 'two',
                   'key2'       => 'three',
                   'key3'       => 'four');

        # $list{'key2'} gives you "three"
        # You can't have another "key2" key,
        # but the same -value- can be
        # associated with multiple keys if
        # desired.


-----
Scot Robnett
inSite Internet Solutions
[EMAIL PROTECTED]



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, December 18, 2002 1:36 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: Confusion on @array vs $array[] vs $array


In a message dated 12/18/2002 12:13:38 PM Eastern Standard Time,
[EMAIL PROTECTED] writes:


>
> Anyway, perhaps one of you syntactical thought police could give me some
> insights to the rational.  I find it very confusing that the $ and @
> characters
> are supposed to be used interchangeably to denote arrays, particularyly
> when I'm
> trying to fathom the relation to other issues such as scalar or list
> context.
> As I recall, hashes arso use % and @ interchangeably.


This about it like this:
The "$" refers to a single piece of information.
The "@" refers to a list.
The "%" refers to an unordered list.

So, if you want to referrer to a specific part of an array, or hash, you
have
to use a $, or scalar. So if your array is
@array = qw(something something2 something3)
Then $array[0] is a scalar value of the first element of the ordered list,
"something".


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to