Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2016-10-22 04:45 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (292 votes). Check out past polls.