Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: conditional enable use bytes for a whole module at compiletime?

by monsieur_champs (Curate)
on Nov 19, 2004 at 13:51 UTC ( #408996=note: print w/replies, xml ) Need Help??


in reply to conditional enable use bytes for a whole module at compiletime?

I think you can say

BEGIN { package Y; $VERSION = 0.1; 1; package X; if ( $Y::VERSION < 1 ) { # How to enable use bytes for the whole modue X? # with condition $Y::VERSION in mind? ## Not use()'d anymore. # use bytes; require bytes; }

And this will do what you mean.

Note: this is untested code, as always.

  • Comment on Re: conditional enable use bytes for a whole module at compiletime?
  • Download Code

Replies are listed 'Best First'.
Re^2: conditional enable use bytes for a whole module at compiletime?
by borisz (Canon) on Nov 19, 2004 at 14:01 UTC
    Hi, no, you think, that my desire is to load the module on a condition, this is not true. I like to enable it on a condition in another scope. For example, this works fine, but I want use bytes only if $Y::VERSION  < 1.
    BEGIN { package Y; $VERSION = 0.1; 1; package X; use bytes; sub l{ return length shift } 1; } package main; no bytes; $x = chr(3456); print X::l($x);
    Boris

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://408996]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2023-03-28 04:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (66 votes). Check out past polls.

    Notices?