perl use syntax help

D

Dave

nan li said:
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.
 
A

A. Sinan Unur

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.

Do you think reading the documentation for the module might help?

NAME

Apache2::Const - Perl Interface for Apache Constants

Synopsis

# make the constants available but don't import them
use Apache2::Const -compile => qw(constant names ...);

# w/o the => syntax sugar
use Apache2::Const ("-compile", qw(constant names ...));
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,379
Messages
2,571,945
Members
48,805
Latest member
CeceliaWri

Latest Threads

Top