Re: perl use syntax help




"nan li" <nan.li.g@xxxxxxxxx> wrote in message
news:1132472294.652684.116010@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Hello,
> I need some help to understand the following statement:
>
> use Apache::Const -compile => 'OK';
>
> It is from the program at
> http://modperlbook.org/html/ch25_02.html. I don't know what it is doing
> here.
> Thanks a lot.
>
> Nan
>

It allows the constant to be used, but it does not import it into the
current package. It allow the following line to work:
return Apache::OK;

had the line been simply:
use Apache::Const 'OK';

the constant (subroutine) OK would have been imported into the namespace
and:
return OK

would have worked. It is not recommended to import the constants in this
second manner as they may conflict with constants imported from other
modules.




.



Relevant Pages

  • Re: modular programming in Forth
    ... It doesn't necessarily mean loading A and B twice ~ only under your ... And, indeed, "App" could well resolve the conflict by placing an A- ... Versus being certainly left with conflicts between the module system ... namespace it prefers, ...
    (comp.lang.forth)
  • Re: use-package & name conflict: why they are not deferred?
    ... resolving a reference of an identifier to a symbol). ... variable, class, namespace, aggregate member, goto label, etc. ... conflict resolution style that matters. ...
    (comp.lang.lisp)
  • Re: Do namespaces make sense here?
    ... >> your example you reduced the chance for a name conflict with one name by ... If every class had its own unique namespace, ... >> conflict, and then everyone would be better off without any namespaces. ... Now, in your app, you can choose to never use any using directives or using ...
    (comp.lang.cpp)
  • Re: morning in Python
    ... I think the namespace conflict is rather in cities than in states. ... In some cases, prefixing helps, e.g. you don't call it "York" ... And wasn't the city object bound to ...
    (comp.lang.python)
  • Re: Do namespaces make sense here?
    ... All functionality of the library is ... >If I encapsulate this in a namespace, ... >namespace since only the namespace name could possibly conflict. ...
    (comp.lang.cpp)