> One is called the 'big' arrow (=>) and one is called
> the 'little' arrow (->).
Like Little Horn and Big Horn from the old westerns? ;-)
> The big arrow is used in place of a ',' (comma). Now,
> I just read in the latest Learning Perl that this is
> global (i.e..: you can replace ANY comma with it, but
> I may have misunderstood, have to re-read that again),
Almost, the following is valid:
my $couple = join " & " => qw(Husband Wife);
however, you'll note swapping the big arrow for a comma
doesn't quite work for a hash:
my %hash = ( big city, 'New York',
Little City, 'Mayberru'
);
The special property of the => is to automatically quote
the LHS if it is only a single word word - provided it
doesn't contain certain characters (lke +-/*$%& etc) that
make it look like an EXPR (expression). Then it *may*
be evaluted rather than simply being quoted.
> The little arrow is used for de-referencing:
>
> my %hash=('35'=>'Bob','Chlorine'=>'Blah');
> my $ref = \%hash;
> foreach(keys %{$ref}) {
> print "Key: $_ Value: $ref->{$_}\n";
> }
A better example is the closure:
my $sub = sub { print "Hello " . shift . "\n" };
$sub->("World");
> See perldoc's perlreftut and perldata...
Jonathan Paton
__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]