Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

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


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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2018-04-24 21:51 GMT
Find Nodes?
    Voting Booth?