Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: An Interesting Gotcha With use/require

by fireartist (Chaplain)
on Feb 09, 2005 at 17:02 UTC ( [id://429427]=note: print w/replies, xml ) Need Help??


in reply to An Interesting Gotcha With use/require

Subroutine fileparse_set_fstype redefined at C:/Program Files/Perl/lib/File/Basename.pm line 152 (#1) (W redefine) You redefined a subroutine. To suppress this warning +, say { no warnings; eval "sub name { ... }"; }

Out of interest, does anyone know why the error message suggests wrapping "sub name { ... }" in an eval?

use strict; use warnings; sub foo { print 'x' } { no warnings; sub foo { print 'y' } } foo();
...prints 'y' with no warnings for me.

Replies are listed 'Best First'.
Re^2: An Interesting Gotcha With use/require
by lestrrat (Deacon) on Feb 10, 2005 at 06:37 UTC

    In your code, the first and second sub are declared at compile time. But if you want to dynamically declare a subroutine at run time, you need to wrap it up in an eval block so that that particular piece of code is evaluated only at run time.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-04-20 00:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found