Mark Ross wrote:
>
> Hi all,
Hello,
> I'm wondering if there is a difference between:
>
> $foo{'bar'}
> and
> $foo{bar}
No difference (depending on which version of Perl you are using.)
> Is there any important difference? I prefer to use
> single quotes (my editor handles color coding better
> that way), but in examples I see from the list, etc.
> folks don't seem to use them. Is there a reason why I
> should ditch them?
Have you read the section in perlop on Quote and Quote-like Operators?
Also from perldata:
As in some shells, you can enclose the variable name in
braces to disambiguate it from following alphanumerics.
You must also do this when interpolating a variable into a
string to separate the variable name from a following dou�
ble-colon or an apostrophe, since these would be otherwise
treated as a package separator:
$who = "Larry";
print PASSWD "${who}::0:0:Superuser:/:/bin/perl\n";
print "We use ${who}speak when ${who}'s here.\n";
Without the braces, Perl would have looked for a $whos�
peak, a `$who::0', and a `$who's' variable. The last two
would be the $0 and the $s variables in the (presumably)
non-existent package `who'.
In fact, an identifier within such curlies is forced to be
a string, as is any simple identifier within a hash sub�
script. Neither need quoting. Our earlier example,
`$days{'Feb'}' can be written as `$days{Feb}' and the
quotes will be assumed automatically. But anything more
complicated in the subscript will be interpreted as an
expression.
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]