On Tuesday, September 3, 2002, at 08:26 , Andrew Metcalfe wrote:
[..]
> Once I understood what => and -> were doing, it all made perfect sense...
[..]
thanks for reminding those who have forgotten
that while "=>" may appear to be what in perl is ">="
{ greater than or equal } it is really a "think comma".
cf perldoc perlop
specifically:
" The => digraph is mostly just a synonym for the comma
operator. It's useful for documenting arguments that come
in pairs. As of release 5.001, it also forces any word to
the left of it to be interpreted as a string.
"
hence the habit of some to "quote" and other not to quote
the left hand argument.... eg:
my $hash_ref = {
left_thing => "some value",
second => "some other value"
};
vice:
my $hash_ref = {
'left_thing' => "some value",
'second' => "some other value"
};
eg:
my %hash = ( 'a', 1, 'b', 2 );
while (my ($k, $v) = each %hash ) {
print "$k -> $v \n";
}
%hash = (
a => 3,
b => 4
);
while (my ($k, $v) = each %hash ) {
print "$k -> $v \n";
}
ciao
drieux
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]