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

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(); # ...


Comment on require, import, & barewords by way of constants
Select or Download Code
Replies are listed 'Best First'.
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?

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (10)
As of 2016-02-08 13:40 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (276 votes), past polls