Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re^2: Why " subroutined redefined" warning comes?

by jdtoronto (Prior)
on Nov 04, 2006 at 19:52 UTC ( #582267=note: print w/replies, xml ) Need Help??

in reply to Re: Why " subroutined redefined" warning comes?
in thread Why " subroutined redefined" warning comes?

Obviously is exporting the function into the MAIN namespace. Stop it exporting, then you can do:
use; for (1 .. 1000) { Spinner::spin(); } sub spin { print "i am the second spin() sub\n"; }
and you don't have a duplicate. Depending on the internals of Spinner, you may be able to do:
use Spinner();
to stop it importing into the MAIN namespace.


Replies are listed 'Best First'.
Re^3: Why " subroutined redefined" warning comes?
by joeface (Pilgrim) on Nov 04, 2006 at 20:44 UTC

    Ahhhh... learned something new, thanks to your reply.

    So, yes, I want Spinner to export the spin() function, to save me from having to do Spinner::spin(), but now I know why I have it that way, and what to change if I decide not to export it.

    You've also shown us a different way to keep the subs separate, if need be.


      An option if you don't import it is to alias it to another name in your package.

      use Spinner (); local *s_pin = \&Spinner::spin; s_pin(); spin();

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2022-12-03 18:46 GMT
Find Nodes?
    Voting Booth?

    No recent polls found