in reply to Re: Optional quotes: to use or not to
in thread Optional quotes: to use or not to

foo instead of $foo, buried deeply in a mountain of shit source code. A bareword, meant to be a variable-reference, but acceptable to the Perl compiler.

How would "the Perl compiler" accept 'foo' as a bareword if you were using strict and/or warnings? Couldn't you find the problem immediately if you turned those on?

#! perl # 1134136.pl use strict; my ($bottom, $top); my @mountain = ($bottom, $top, foo); exit;
[05:38][nick:~/monks]$ perl 1134136.pl Bareword "foo" not allowed while "strict subs" in use at 1134136.pl li +ne 4. Execution of 1134136.pl aborted due to compilation errors.
#! perl # 1134136-2.pl use warnings; my ($bottom, $top); my @mountain = ($bottom, $top, foo); exit;
[05:41][nick:~/monks]$ perl 1134136-2.pl Unquoted string "foo" may clash with future reserved word at 1134136-2 +.pl line 5.
Remember: Ne dederis in spiritu molere illegitimi!

Replies are listed 'Best First'.
Re^3: Optional quotes: to use or not to
by u65 (Chaplain) on Jul 10, 2015 at 14:38 UTC

    Strict wouldn't catch this would it:

    my %h; $h{foo} = 82;