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
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]