in reply to runtime eval() and constants

That's so that you can write:

package Some::Module;

instead of:

package "Some::Module";

Bow before you ;)

Replies are listed 'Best First'.
Re: runtime eval() and constants
by Abigail-II (Bishop) on Dec 08, 2003 at 16:46 UTC
    Eh, no. package and require are special cased - their arguments won't trigger the "unquoted string" warning. But it does matter for method calls:
    $ perl -wce 'require foo' -e syntax OK $ perl -wce 'package foo' -e syntax OK $ perl -wce 'foo -> method' Unquoted string "foo" may clash with future reserved word at -e line 1 +. -e syntax OK $ perl -wce 'Foo -> method' -e syntax OK
    It also matters for filehandles:
    $ perl -wce 'print Foo' Name "main::Foo" used only once: possible typo at -e line 1. -e syntax OK $ perl -wce 'print foo' Unquoted string "foo" may clash with future reserved word at -e line 1 +. Name "main::foo" used only once: possible typo at -e line 1. -e syntax OK

    Abigail

      Note that a bareword before the -> is subject to interpretation as a function call if there is such a function:
      $ perl -we'sub Foo { "Bar" } Foo -> method' Can't locate object method "method" via package "Bar" (perhaps you for +got to load "Bar"?) at -e line 1.
      You can force its interpretation as a class name by saying Bar::->method (no, that doesn't call &Bar:: even if you go out of your way to define such an evilly named sub) or "Bar"->method.

      In a module or in a program using other's modules, you should do this all the time. After all, your code may have done use Some::Module and established a contract with that module, but when you say Some::Module->classmethod you are implicitly making an assumtion about the module Some, which you have no arrangement with.