Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

require, import, & barewords by way of constants

by Anonymous Monk
on Apr 24, 2012 at 15:46 UTC ( #966881=perlmeditation: print w/ replies, xml ) Need Help??

# ... use strict; # ... require Fcntl; import Fcntl ':mode'; my $default = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH; # ...

That caused fatal errors by virtue of S_* constants being barewords. They are not recognized as subs during the compile time (since above happens outside of BEGIN), thus cause the "bareword" error.

Add () and one is back in business ...

# ... use strict; # ... require Fcntl; import Fcntl ':mode'; my $default = S_IRUSR() | S_IWUSR() | S_IRGRP() | S_IWGRP() | S_IRO +TH(); # ...

CON#$T&ANT;!()

Comment on require, import, & barewords by way of constants
Select or Download Code
Re: require, import, & barewords by way of constants
by Corion (Pope) on Apr 24, 2012 at 15:53 UTC

    If you want the routines imported at compile time, why do you want to use require+import? Perl has use to import symbols at compile time for just that reason.

      I am aware of that; I did not want to import at compile time, only during run time.

      A constant, rather a usable sub without parentheses, it is not then when one goes from the document using use to code using require. OTOH, object reference use is just dandy of course.

      This is also a reminder to self yet again about constant|function-call-with-optional-parentheses usage.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://966881]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (14)
As of 2014-07-25 16:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (173 votes), past polls