"Fliptop" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > 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. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]