[Nh-pm] quoting list keys & values
Ben Boulanger
ben at blackavar.com
Fri Aug 2 08:51:04 CDT 2002
On Thu, 1 Aug 2002, Erik Price wrote:
> So (apparently), Perl and PHP are similar in that quoting hash keys is
> not enforced, nor is quoting list values that are string literals? So
> then, that begs the logical question, is it considered good form to
> quote string literals in Perl (as in PHP) to avoid confusion with string
> constants, or is that a personal choice?
It -is- considered good form to quote strings in Perl. In fact, all of
the perl scripts I write begin with perl -w and use strict - strict subs
disallows unknown barewords (AFAIK) completely, where -w (warnings on)
warns you about them. For example:
[bboulanger at .. bboulanger]$ perl -e 'use strict; my $junk = blah;'
Bareword "blah" not allowed while "strict subs" in use at -e line 1.
Execution of -e aborted due to compilation errors.
[bboulanger at .. bboulanger]$ perl -we 'my $junk = blah;'
Unquoted string "blah" may clash with future reserved word at -e line 1.
As for advice - I agree with Kevin - use #!/.../perl -w and use strict
Ben
--
Better to light a candle than to curse the darkness
More information about the Nh-pm
mailing list