Why is the following use
line legal Perl syntax? (Adapted from the POD for parent; tested on Perl 5.26.2 x64 on Cygwin.)
package MyHash;
use strict;
use Tie::Hash;
use parent -norequire, "Tie::StdHash";
# ^^^^^^^^^^ A bareword with nothing to protect it!
Under -MO=Deparse
, the use
line becomes
use parent ('-norequire', 'Tie::StdHash');
but I can't tell from the use
docs where the quoting on -norequire
comes from.
If
use strict
were not in force, I would understand it. The barewordnorequire
would become the string"norequire"
, the unary minus would turn that string into"-bareword"
, and the resulting string would go into theuse
import list. For example:package MyHash; use Tie::Hash; use parent -norequire, "Tie::StdHash";
Similarly, if there were a fat comma, I would understand it.
-foo => bar
becomes"-foo", bar
because=>
turnsfoo
into"foo"
, and then the unary minus works its magic again. For example:package MyHash; use strict; use Tie::Hash; use parent -norequire => "Tie::StdHash";
Both of those examples produce the same deparse for the use
line. However, both have quoting that the original example does not. What am I missing that makes the original example (with strict
, without =>
) legal? Thanks!
Foo->bar
is not'Foo'->bar
if a sub Foo exists, it isFoo()->bar
. You should useFoo::->bar
or'Foo'->bar
. – Shrieval