Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Is this fundamentally different than my original try?

by joshclark (Novice)
on Sep 28, 2003 at 14:02 UTC ( #294745=note: print w/ replies, xml ) Need Help??


in reply to Re^2: use bytes without breaking perl 5.005 or 5.004? (also)
in thread use bytes without breaking perl 5.005 or 5.004?

Thanks Tye! Applying this to "use bytes," am I correct that your solution is basically the same approach as the one I originally suggested? In other words, isn't this...
BEGIN { if( eval { require bytes } ) { bytes->import(); } }
...pretty much the same as this:
BEGIN { eval {require bytes; import bytes; 1} }
I'm a bit new to trying to import modules and pragmas outside of the regular "use" function, so I'm just trying to be sure that I understand the difference, if any.

Thanks! Josh


Comment on Is this fundamentally different than my original try?
Select or Download Code
Re^4: use bytes without breaking perl 5.005 or 5.004? (same)
by tye (Cardinal) on Sep 29, 2003 at 03:56 UTC

    Yes, same result. Here is how I tested it:

    > perl { use warnings; } print $x; <EOF> > perl BEGIN { if( {require warnings} ) { warnings->import(); } } print $x; <EOF> Use of uninitialized value in print at - line 3. > perl BEGIN { eval { require warnings; import warnings; } } print $x; <EOF> Use of uninitialized value in print at - line 3. >
    First is the "control" case to show that 'use warnings' inside of a block doesn't have an effect outside of the block. Next is my method, and the warning generated shows that there is an effect (since I have warnings.pm in this version of Perl). Last is your method, which also works.

    The 'hint' pragmas all work very much the same so this trick works for 'strict', 'warnings', 'bytes', etc.

                    - tye

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (11)
As of 2014-07-25 13:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (172 votes), past polls