in reply to Why perl with strict allows to use -bareword?

it may cause a surprise, when sub with name 'base' been defined before this use

That doesn't make sense: if sub blah has been defined then blah and -blah are not barewords, they are function calls

use warnings; use strict; BEGIN { $INC{'Blah.pm'}=1 } sub Blah::import { print "@_\n" } sub abc { 42 } use Blah -abc; # "Blah -42" use Blah -def; # "Blah -def"

Replies are listed 'Best First'.
Re^2: Why perl with strict allows to use -bareword?
by Anonymous Monk on Jun 27, 2017 at 20:40 UTC
    What the parser considers a bareword does depend on what it's seen tho.
    use warnings; use strict; BEGIN { $INC{'Blah.pm'}=1 } sub Blah::import { print "@_\n" } sub abc { 42 } use Blah -abc; # "Blah -42" use Blah -def; # *still* "Blah -def" sub def { 999 }
    Barewords: "A word that has no other interpretation in the grammar will be treated as if it were a quoted string. ... use strict 'subs'; then any bareword that would NOT be interpreted as a subroutine call produces a compile-time error instead."
Re^2: Why perl with strict allows to use -bareword?
by hurricup (Pilgrim) on Jun 28, 2017 at 05:18 UTC
    Yes, and I expected compilation failure if sub with such name was not defined. According to docs.