Confusion on @array vs $array[] vs $array

--=_FCA3CF00.8EEF86D1
Content-Type: text/plain; 
 charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hello:

I have been fairly confused on the intermixing of array naming standards.  If I
understand correctly, the @array syntaxt is used to refer to the whole array,
while $array[n] is refered to specific elements.

In my thinking, it would have been less confusing to use @array[n] to address
specific elements, but Perl complaines bitterly when warnings &/or strict is
enabled.

Is the rational for the "$"array[] character for identifying "@"array elements
due to the fact that the $ character has special meaning (denotes variable or
element) within double quoted text, while the @ sign has no special meanign
within double quotes.

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.

Thanks,

Lance

------------------------------------------------------------------------------
#!/usr/bin/perl
print "Lance Murray, Information and Communications Systems\n",  # department
"The Church of Jesus Christ of Latter-Day Saints\n",  # employer and religion
"(801) 240-6583, murraylk\@ldschurch.org\n\n",  # work phone number and email
"\"Better to do a little well than a lot poorly (Socrates)\"\n"; # philosophy
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print

------------------------------------------------------------------------------
This message may contain confidential information, and is intended only for the use of the individual(s) to whom it is addressed.


==============================================================================

--=_FCA3CF00.8EEF86D1
Content-Type: text/plain; 
 charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; 
 filename="Lance Murray.vcf"

BEGIN:VCARD
VERSION:2.1
X-GWTYPE:USER
FN:Lance Murray
N:Murray;Lance
TITLE:Network Engineer
TEL;WORK:+1-801-240-6583
TEL;PREF;FAX:+1-801-240-5237
ORG:;Info. and Comm. Sys.
ADR;DOM;WORK;PARCEL;POSTAL:;CCC 216A-16;125 North State;Salt Lake City;Utah;84103
LABEL;DOM;WORK;PARCEL;POSTAL;ENCODING=QUOTED-PRINTABLE:Lance Murray=0A=
CCC 216A-16=0A=
125 North State=0A=
Salt Lake City, Utah  84103
EMAIL;WORK;PREF;NGW:MurrayLK@ldschurch.org
END:VCARD


--=_FCA3CF00.8EEF86D1--

0
MurrayLK
12/18/2002 5:02:04 PM
perl.beginners.cgi 3838 articles. 0 followers. Follow

9 Replies
635 Views

Similar Articles

[PageSpeed] 42

My understanding is that it's simpler than that. @ means list and $ means
scalar, and essentially one element in a list is really a scalar. $foo[0]
gets you the first scalar from the list @foo.

	$count = scalar(@foo);

gets you a count of all the elements in the list. At least to me the @/$
conventions make things *less* confusing, not more.

-----
Scot Robnett
inSite Internet Solutions
scot@insiteful.tv




-----Original Message-----
From: Lance Murray [mailto:MurrayLK@ldschurch.org]
Sent: Wednesday, December 18, 2002 11:02 AM
To: beginners-cgi@perl.org
Subject: Confusion on @array vs $array[] vs $array


Hello:

I have been fairly confused on the intermixing of array naming standards.
If I
understand correctly, the @array syntaxt is used to refer to the whole
array,
while $array[n] is refered to specific elements.

In my thinking, it would have been less confusing to use @array[n] to
address
specific elements, but Perl complaines bitterly when warnings &/or strict is
enabled.

Is the rational for the "$"array[] character for identifying "@"array
elements
due to the fact that the $ character has special meaning (denotes variable
or
element) within double quoted text, while the @ sign has no special meanign
within double quotes.

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.

Thanks,

Lance

----------------------------------------------------------------------------
--
#!/usr/bin/perl
print "Lance Murray, Information and Communications Systems\n",  #
department
"The Church of Jesus Christ of Latter-Day Saints\n",  # employer and
religion
"(801) 240-6583, murraylk\@ldschurch.org\n\n",  # work phone number and
email
"\"Better to do a little well than a lot poorly (Socrates)\"\n"; #
philosophy
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub
p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^or
d
($p{$_})&6];$p{$_}=/
^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep
rand(2)if/\S/;print

----------------------------------------------------------------------------
--
This message may contain confidential information, and is intended only for
the use of the individual(s) to whom it is addressed.


============================================================================
==

0
scot
12/18/2002 5:24:08 PM
I can see where you're coming from on this. However the most obvious reason is that perl has no relationship in scalar context between @somename and %somename.

Your question regarding the "special" $ is not germane to this concept. Each element of the array is a separate scalar variable, accessed by each key of the index. Therefore to retrieve a scalar value, you must use a scalar reference. In this case $key. Other wise you would be asking Perl to find @key (a list) which really doesn't exist. That's unless of course you had created it. That's the way I see the thing.


-----Original Message-----
From: "Lance Murray"<MurrayLK@ldschurch.org>
To: beginners-cgi@perl.org
Date: Wed Dec 18 09:02:04 PST 2002
Subject: Confusion on @array vs $array[] vs $array

>Hello:
>
>I have been fairly confused on the intermixing of array naming standards.  If I
>understand correctly, the @array syntaxt is used to refer to the whole array,
>while $array[n] is refered to specific elements.
>
>In my thinking, it would have been less confusing to use @array[n] to address
>specific elements, but Perl complaines bitterly when warnings &/or strict is
>enabled.
>
>Is the rational for the "$"array[] character for identifying "@"array elements
>due to the fact that the $ character has special meaning (denotes variable or
>element) within double quoted text, while the @ sign has no special meanign
>within double quotes.
>
>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.
>
>Thanks,
>
>Lance
>
>------------------------------------------------------------------------------
>#!/usr/bin/perl
>print "Lance Murray, Information and Communications Systems\n",  # department
>"The Church of Jesus Christ of Latter-Day Saints\n",  # employer and religion
>"(801) 240-6583, murraylk\@ldschurch.org\n\n",  # work phone number and email
>"\"Better to do a little well than a lot poorly (Socrates)\"\n"; # philosophy
>@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
>@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
>($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
>close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
>
>------------------------------------------------------------------------------
>This message may contain confidential information, and is intended only for the use of the individual(s) to whom it is addressed.
>
>
>==============================================================================


___________________________________________________
GO.com Mail                                    
Get Your Free, Private E-mail at http://mail.go.com


0
giglmon
12/18/2002 6:04:11 PM
@var is an array
$var is a scalar

$var[0] is also a scalar even though is an array element.
@var[0] is an array which contains more array elements, but in this case it
contains just a single element.

To create an array slice with more elements, you'll need something like
@var[0 .. n]

You need to always use $ for scalars and @ for arrays.


Teddy,
Teddy's Center: http://teddy.fcc.ro/
Email: orasnita@home.ro

----- Original Message -----
From: "Lance Murray" <MurrayLK@ldschurch.org>
To: <beginners-cgi@perl.org>
Sent: Wednesday, December 18, 2002 7:02 PM
Subject: Confusion on @array vs $array[] vs $array


Hello:

I have been fairly confused on the intermixing of array naming standards.
If I
understand correctly, the @array syntaxt is used to refer to the whole
array,
while $array[n] is refered to specific elements.

In my thinking, it would have been less confusing to use @array[n] to
address
specific elements, but Perl complaines bitterly when warnings &/or strict is
enabled.

Is the rational for the "$"array[] character for identifying "@"array
elements
due to the fact that the $ character has special meaning (denotes variable
or
element) within double quoted text, while the @ sign has no special meanign
within double quotes.

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.

Thanks,

Lance

----------------------------------------------------------------------------
--
#!/usr/bin/perl
print "Lance Murray, Information and Communications Systems\n",  #
department
"The Church of Jesus Christ of Latter-Day Saints\n",  # employer and
religion
"(801) 240-6583, murraylk\@ldschurch.org\n\n",  # work phone number and
email
"\"Better to do a little well than a lot poorly (Socrates)\"\n"; #
philosophy
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub
p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^or
d
($p{$_})&6];$p{$_}=/
^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep
rand(2)if/\S/;print

----------------------------------------------------------------------------
--
This message may contain confidential information, and is intended only for
the use of the individual(s) to whom it is addressed.


============================================================================
==



----------------------------------------------------------------------------
----


--
To unsubscribe, e-mail: beginners-cgi-unsubscribe@perl.org
For additional commands, e-mail: beginners-cgi-help@perl.org

0
orasnita
12/18/2002 6:13:58 PM
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
scot@insiteful.tv



-----Original Message-----
From: WilliamGunther@aol.com [mailto:WilliamGunther@aol.com]
Sent: Wednesday, December 18, 2002 1:36 PM
To: MurrayLK@ldschurch.org; beginners-cgi@perl.org
Subject: Re: Confusion on @array vs $array[] vs $array


In a message dated 12/18/2002 12:13:38 PM Eastern Standard Time,
MurrayLK@ldschurch.org 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".

0
scot
12/18/2002 8:20:02 PM
Hope this doesn't further belabor the issue, but just to put my 
two cents in, Perl syntactic rules for prefixing "$", "@", "%" are 
very consistent, IMHO: You just need to keep in mind the types of 
the values/data types ultimately being expressed, and it should 
become clearer. "$" always prefixes scalars or references, "@" 
always prefixes lists, and "%" always prefixes associative arrays 
(a.k.a hashes).

@array is a list
$array[n] is a scalar/reference 
%hash is a hash
$hash{'key'} is a scalar/reference
@$ref dereferences a reference to an array, accessing the array In 
this case, "print $ref;" would give you a reference scalar, 
something like "ARRAY(0x4E3FB1C)"; "print @$ref;" would output the 
actual array list.

Also try @hash{keys %hash}, which returns a list of the hash's 
values.

In all these cases, the prefixed "sigils" consistently describe 
the data type ultimately expressed, rather than the data type of 
the originating variable's data structure.

Kevin



---------- Original Message ----------------------------------
From: "Octavian Rasnita" <orasnita@home.ro>
Date:  Wed, 18 Dec 2002 20:13:58 +0200

>@var is an array
>$var is a scalar
>
>$var[0] is also a scalar even though is an array element.
>@var[0] is an array which contains more array elements, but in 
this case it
>contains just a single element.
>
>To create an array slice with more elements, you'll need 
something like
>@var[0 .. n]
>
>You need to always use $ for scalars and @ for arrays.
>
>
>Teddy,
>Teddy's Center: http://teddy.fcc.ro/
>Email: orasnita@home.ro
>
>----- Original Message -----
>From: "Lance Murray" <MurrayLK@ldschurch.org>
>To: <beginners-cgi@perl.org>
>Sent: Wednesday, December 18, 2002 7:02 PM
>Subject: Confusion on @array vs $array[] vs $array
>
>
>Hello:
>
>I have been fairly confused on the intermixing of array naming 
standards.
>If I
>understand correctly, the @array syntaxt is used to refer to the 
whole
>array,
>while $array[n] is refered to specific elements.
>
>In my thinking, it would have been less confusing to use @array
[n] to
>address
>specific elements, but Perl complaines bitterly when warnings 
&/or strict is
>enabled.
>
>Is the rational for the "$"array[] character for 
identifying "@"array
>elements
>due to the fact that the $ character has special meaning (denotes 
variable
>or
>element) within double quoted text, while the @ sign has no 
special meanign
>within double quotes.
>
>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.
>
>Thanks,
>
>Lance
>
>------------------------------------------------------------------
----------
>--
>#!/usr/bin/perl
>print "Lance Murray, Information and Communications Systems\n",  #
>department
>"The Church of Jesus Christ of Latter-Day Saints\n",  # employer 
and
>religion
>"(801) 240-6583, murraylk\@ldschurch.org\n\n",  # work phone 
number and
>email
>"\"Better to do a little well than a lot poorly (Socrates)\"\n"; #
>philosophy
>@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona 
tsuJ";sub
>p{
>@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map
{$P=$P[$f^or
>d
>($p{$_})&6];$p{$_}=/
>^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
>close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep
>rand(2)if/\S/;print
>
>------------------------------------------------------------------
----------
>--
>This message may contain confidential information, and is 
intended only for
>the use of the individual(s) to whom it is addressed.
>
>
>==================================================================
==========
>==
>
>
>
>------------------------------------------------------------------
----------
>----
>
>
>--
>To unsubscribe, e-mail: beginners-cgi-unsubscribe@perl.org
>For additional commands, e-mail: beginners-cgi-help@perl.org
>
>
>-- 
>To unsubscribe, e-mail: beginners-cgi-unsubscribe@perl.org
>For additional commands, e-mail: beginners-cgi-help@perl.org
>
>

0
kevinchristopher
12/18/2002 8:49:38 PM
--part1_15b.192b856e.2b32281c_boundary
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit

In a message dated 12/18/2002 12:13:38 PM Eastern Standard Time, 
MurrayLK@ldschurch.org 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". 

--part1_15b.192b856e.2b32281c_boundary--
0
WilliamGunther
12/18/2002 10:35:56 PM
And, for increased flexibility (strict/warn OK)

my @array = ( 10,20,30,40); my %array = @array;

my %hash = (1,2,3,4); my @hash = %hash;

print "Array Element \$array[1] = $array[1]\n";

print "Hash Element \$hash{'1'} = $hash{'1'}\n";

print "Array Hash Element \$array{'10'} = $array{'10'}\n";

print "Hash Array Element \$hash[1] = $hash[1]\n";

Enjoy!

> -----Original Message-----
> From: Lance Murray [mailto:MurrayLK@ldschurch.org]
> Sent: Wednesday, December 18, 2002 11:02 AM
> To: beginners-cgi@perl.org
> Subject: Confusion on @array vs $array[] vs $array
> 
> Hello:
> 
> I have been fairly confused on the intermixing of array naming standards.
> If I
> understand correctly, the @array syntaxt is used to refer to the whole
> array,
> while $array[n] is refered to specific elements.
> 
> In my thinking, it would have been less confusing to use @array[n] to
> address
> specific elements, but Perl complaines bitterly when warnings &/or strict is
> enabled.
> 
> Is the rational for the "$"array[] character for identifying "@"array
> elements
> due to the fact that the $ character has special meaning (denotes variable
> or
> element) within double quoted text, while the @ sign has no special meanign
> within double quotes.
> 
> 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.
> 
> Thanks,
> 
> Lance
>
0
a
12/19/2002 10:14:29 AM
On Wed, 18 Dec 2002 at 13:49, kevin christopher opined:

kc:Hope this doesn't further belabor the issue, but just to put my 
kc:two cents in, Perl syntactic rules for prefixing "$", "@", "%" are 
kc:very consistent, IMHO: You just need to keep in mind the types of 
kc:the values/data types ultimately being expressed, and it should 
kc:become clearer. "$" always prefixes scalars or references, "@" 
kc:always prefixes lists, and "%" always prefixes associative arrays 
kc:(a.k.a hashes).
kc:
kc:@array is a list
kc:$array[n] is a scalar/reference 
kc:%hash is a hash
kc:$hash{'key'} is a scalar/reference
kc:@$ref dereferences a reference to an array, accessing the array In 
kc:this case, "print $ref;" would give you a reference scalar, 
kc:something like "ARRAY(0x4E3FB1C)"; "print @$ref;" would output the 
kc:actual array list.
kc:
kc:Also try @hash{keys %hash}, which returns a list of the hash's 
kc:values.

i hope everyone realizes that all this will be changed in perl 6.  here's
a snippet from a slideshow by damian conway from the summer 2001:

Access through...    Perl 5          Perl 6
Array variable     $foo[$idx]      @foo[$idx]
Array slice        @foo[@idxs]     @foo[@idxs]
Hash variable      $foo{$key}      %foo{$key}
Hash slice         @foo{@keys}     %foo{@keys}
Scalar variable    $foo            $foo
Array reference    $foo->[$idx]    $foo.[$n]
Hash reference     $foo->{$key}    $foo.{$key}
Code reference     $foo->(@args)   $foo.(@args)

the complete slideshow can be found here as a pdf document:

http://dev.perl.org/perl6/talks/Perl6-Notes-200108.v2.pdf

it was also reported in the p6p digest from august 5-11, 2001:

http://www.perl.com/pub/a/2001/08/p6pdigest/20010811.html

0
fliptop
12/19/2002 2:14:42 PM
"Fliptop" <fliptop@peacecomputers.com> wrote in message
news:Pine.LNX.4.44.0212190907250.25505-100000@zeppelin.localdomain.local...
> On Wed, 18 Dec 2002 at 13:49, kevin christopher opined:
>
> kc:Hope this doesn't further belabor the issue, but just to put my
> kc:two cents in, Perl syntactic rules for prefixing "$", "@", "%" are
> kc:very consistent, IMHO: You just need to keep in mind the types of
> kc:the values/data types ultimately being expressed, and it should
> kc:become clearer. "$" always prefixes scalars or references, "@"
> kc:always prefixes lists, and "%" always prefixes associative arrays
> kc:(a.k.a hashes).
> kc:
> kc:@array is a list
> kc:$array[n] is a scalar/reference
> kc:%hash is a hash
> kc:$hash{'key'} is a scalar/reference
> kc:@$ref dereferences a reference to an array, accessing the array In
> kc:this case, "print $ref;" would give you a reference scalar,
> kc:something like "ARRAY(0x4E3FB1C)"; "print @$ref;" would output the
> kc:actual array list.
> kc:
> kc:Also try @hash{keys %hash}, which returns a list of the hash's
> kc:values.
>
> i hope everyone realizes that all this will be changed in perl 6.  here's
> a snippet from a slideshow by damian conway from the summer 2001:
>
> Access through...    Perl 5          Perl 6
> Array variable     $foo[$idx]      @foo[$idx]
> Array slice        @foo[@idxs]     @foo[@idxs]
> Hash variable      $foo{$key}      %foo{$key}
> Hash slice         @foo{@keys}     %foo{@keys}
> Scalar variable    $foo            $foo
> Array reference    $foo->[$idx]    $foo.[$n]
> Hash reference     $foo->{$key}    $foo.{$key}
> Code reference     $foo->(@args)   $foo.(@args)
>
The dereferencing isnt going to be _that_ bad. Since a .[, .{, or .( after a
string preceeded by a $ implies dereferencing, the . can be dispensed.

From Exgenesis 2: http://www.perl.com/pub/a/2001/05/08/exegesis2.html

Here's a handy conversion table:
        Access through...       Perl 5          Perl 6
        =================       ======          ======
        Scalar variable         $foo            $foo
        Array variable          $foo[$n]        @foo[$n]
        Hash variable           $foo{$k}        %foo{$k}
        Array reference         $foo->[$n]      $foo[$n] (or $foo.[$n])
        Hash reference          $foo->{$k}      $foo{$k} (or $foo.{$k})
        Code reference          $foo->(@a)      $foo(@a) (or $foo.(@a))
        Array slice             @foo[@ns]       @foo[@ns]
        Hash slice              @foo{@ks}       %foo{@ks}beautiful =0)

Todd W.


0
trw3
12/20/2002 8:55:35 PM
Reply:

Similar Artilces:

Arrays, Arrays, Arrays
I mainly come from a JScript classic ASP background and I'm liking both C#.net and JScript.net. Now I have to say... "What's happened to arrays?" They used to be so flexible and easy to use. Here are my quick questions... Am I allowed to create an array with a non specified length so that I can add to it? If not then how can I modify an array's length? Can I create an array with a named index eg myArray["apple"] = "tasty"; or is the hash table the equivalent for this now? The classic array methods and properties like pop(), push(), length etc... are ...

Concatenating arrays from arrays of arrays
Hello - I am trying to accumulate items in a flat list (array) by concatenating on to it the scalars contained in arrays which in turn are contained in arrays. The data is to be read in from a file rather than existing as literals in my code. Everything I try either crashes the computer or gives me an array of arrays instead of a flat list. I have been programming in Unicon which has a concatenate operator, but Perl makes very heavy weather of nested list management. Should I switch to Lisp, or is there a way of doing what I want to do in Perl? Regards _John Sampson_ On...

referring to an array in an array of arrays
How can I get at an array in an array of arrays? I'm creating the arrays using: $fComments[$i++] = [ @comments ]; Now I want to get back what I put in: print "$fComments[0]\n"; but this prints ARRAY(0x107671f0). How do I follow that pointer? (I really think we need a pre-beginners list... =) TIA. - B You can try something like this: print "@{$fComments[0]}\n"; Which will attempt to dereference the array at $fComments[0]. -----Original Message----- From: Bryan R Harris [mailto:Bryan_R_Harris@raytheon.com] Sent: Tue...

How to unshift to an array in an array of arrays?
How to unshift to an array in an array of arrays? > -----Original Message----- > From: Angerstein [mailto:ang@nmc-m.dtag.de] > Sent: Wednesday, August 28, 2002 6:12 AM > To: beginners@perl.org > Subject: How to unshift to an array in an array of arrays? > > > How to unshift to an array in an array of arrays? $ perl -d -e 1 ..... DB<1> @aoa = ([qw(foo bar baz)]) << create array of arrays DB<2> x @aoa 0 ARRAY(0x80f82dc) 0 'foo' 1 'bar' 2 'baz' DB<3> unshift @{$aoa[0]}, 'qu...

array of arrays
Hi. =20 Im using a multidimensional array in the following way: $array[$i][$j][$k] =3D [ @list ]; where, @list is a 2-D array ie. = $list[][]. How do I access the individual elements of the array @list once Ive put it = into the array @array? Thanks. -ty On Thu, Oct 18, 2001 at 02:28:41PM -0600, Tyler Cruickshank wrote: > $array[$i][$j][$k] = [ @list ]; where, @list is a 2-D array ie. $list[][]. > > How do I access the individual elements of the array @list once Ive put it > into the array @array? $array[$i][$j][$k][$l][$m] eq $list[$l][$m] Howev...

Array of Arrays
Hi, I am looking for a way to create an array of arrays which needs to be passed to Oracle database to minimize the round trips to hte server. I was successful in sending simple arrays so far but no idea on how to create array of arrays in PB. I have used structures to simulate this but looks like I can't send the PB structure to Oracle. Anyone has any suggestions? Thanks, Anil PB 11 or 12 I believe will have this native. <Anil> wrote in message news:422789a4.721c.1681692777@sybase.com... > Hi, > > I am looking for a way to create an array of ar...

array of arrays
Hi, I have a simple question: how do I access an array in an array? @array = (@array1, array2); ### unless this is wrong... the idea behind it is, that I have a long list, and want to put all 25 entries in a seperate array in that big array. later on I want to be able to read one specific array at a certain position... -- cheers alex mailto:Keex@gmx.de you need to learn about references. read the: perldoc perllol here is the jist though. @all = (\@array1, \@array2 ... ); # ... so on to access first array and first element...

Array of Array.
How is possible to declare a DYNAMIC array of array ? I need something like a dynamic hash table whose pages grow up dynamically too (each one can have different number of elements). In other words, a matrix that can be dynamic in both dimension. example: [1,2,3...] [3,4..] [5] [6,7,8,9...] [.] .. .. .. Have you considered using a DataStore? -- <hopethishelps/> Roy Kiesler [TeamSybase] SDN CodeXchange -- http://codexchange.sybase.com "Marco Meoni - News" <mmeoni@usl4.toscana.it> wrote in message news:401ba036$1@forums-2-dub... > How ...

[@array] and \@array
Given the case, my @array = (1,2,3,4); my $var1 = [@array]; my $var2 = \@array; What's the difference between $var1 and $var2? Are they all refered to @array? Thanks guys. On 3/22/07, Jm lists <practicalperl@gmail.com> wrote: > Given the case, > > my @array = (1,2,3,4); > my $var1 = [@array]; > my $var2 = \@array; > > What's the difference between $var1 and $var2? > Are they all refered to @array? > Thanks guys. $var2 is a reference to @array. $var1 is a reference to new array. Observe #!/usr/bin/perl use strict; use war...

An array of arrays
Could anybody help me out here? Here's the message I just got from a guy I know: ----------- I was wondering if you know how to create and access an array of arrays in Perl. Basically I'm parsing an exported text file containing e-mails and I think I want to move some fields into arrays until I'm ready to do my report. Here basically is what I'm looking at doing: ^ | | Array 1 (messages) | | v <------ Array 2 -------> (message fields:FROM, TO, CC, etc, sensitivity, etc) I want to be able to search through the first array to count how many messag...

Array of Arrays
Hi, I am looking for a way to create an array of arrays which needs to be passed to Oracle database to minimize the round trips to hte server. I was successful in sending simple arrays so far but no idea on how to create array of arrays in PB. I have used structures to simulate this but looks like I can't send the structure to Oracle. Anyone has any suggestions? Thanks, Anil Please don't cross-post. On 3 Mar 2005 14:02:47 -0800, Anil wrote: >Hi, > >I am looking for a way to create an array of arrays which >needs to be passed to Oracle database t...

Array of arrays
Hi I'm trying to return from a web service a array of arrays, one of the arrays is a array of objects, which I tested separately and it's working fine, and another array of integer and another of strings. When I run the web service I got this:You must implement a default accessor on System.Array because it inherits from ICollectionDefault accessor what that means? Thank you very much.  As Heinlein said "specialization is for insects" explore beyond the universe. Could you pls post the relevant code ? hi rushan thank you for the reply the code is here:  ...

Array.copy vs Array.clone
can any one give the Difference between Array.copy and Array.clone  with an example   Thanks in Advance Clone() just implements the ICloneable interface. It creates new instance of array holding the same elements, but returns object you have to cast. ArrayCopy() is static helper method. It copies elements from one array to another. The destination array has to be already created with right dimension. You can use this method instead for loop.Don't forget to click "Mark as Answer" on the post that helped you. Hi Praveen, ... and welcome to our forum ...! ar...

String Array vs Array List
Which one is better to use?  String Array vs Array List  Johan TheunissenMCPD, MCSE, MCTS BizTalk 2006==============================Please mark the most helpful reply/replies as "Answer". Take a look into the below link http://detritus.blogs.com/lycangeek/2005/09/array_vs_arrayl.html HCHaissam Abdul MalakMCAD.NET| Blog |...

Web resources about - Confusion on @array vs $array[] vs $array - perl.beginners.cgi

Confusion of tongues - Wikipedia, the free encyclopedia
... humanity spoke a single language, either identical to or derived from the " Adamic language " spoken by Adam and Eve in Paradise. In the confusion ...

New Facebook Friend Lists Cause Some Confusion
Facebook's new profiles include the ability to share friend lists, but how they function is not completely clear to users.

Advertiser Confusion Led to Shutdown of Facebook Conversion Tracking Tool
When Facebook closed a private beta of a conversion tracking tool earlier this month that would have allowed advertisers to see whether users ...

Confusion (@PigsAndPlans) on Twitter
Sign in Sign up To bring you Twitter, we and our partners use cookies on our and other websites. Cookies help personalize Twitter content, tailor ...

Rebuttal to Andrew Sullivan: Blogs are an amateur thing, that's the source of confusion.
Rebuttal to Andrew Sullivan: Blogs are an amateur thing, that's the source of confusion.

SCOTUS Preview: Trademark Confusion - Jason P. Steed
... (There's still time for them to add more.) Here's a quick preview of one of them:In B&B Hardware, Inc. v. SCOTUS Preview: Trademark Confusion ...

Confusion Corner - Flickr - Photo Sharing!
The thing I like best is the two different arrows pointing "north".

Disturbed - Land Of Confusion [Official Music Video] - YouTube
Chicago, Illinois metal band Disturbed has successful mixed aggressive riffs and vocals with a melodic approach to form a winning formula that ...

In confusion-filled David de Gea fallout, Manchester United get last word over Real Madrid
Manchester United's statement on Tuesday clarified things only to a small extent, but ultimately in the public dispute with Real Madrid, what ...

Short Film of the Day: ‘Confusion Through Sand’ Illustrates the Fog of War
... “(Notes on) Biology,” has released their latest award-winning film online, an animated commentary on the haze and horror of war called “Confusion ...

Resources last updated: 12/19/2015 1:12:03 AM