Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Making Coro::Socket Override IO::Socket::INET

by aitap (Deacon)
on Jun 17, 2013 at 18:14 UTC ( #1039435=note: print w/ replies, xml ) Need Help??


in reply to Making Coro::Socket Override IO::Socket::INET

You can probably acheive this by altering the symbol table:

package Bar; sub import { print "Hi!\n"; } package main; use warnings; use strict; BEGIN{*{Foo::} = *{Bar::};} # can't "use" there because there is no Foo.pm Foo::->import; __END__ Hi!

Write a header in your script that once uses Coro::Socket and then replaces IO::Socket::INET:: namespace with Coro::Socket::. Subsequent uses of IO::Socket::INET will call import() from Coro::Socket and will use its subroutines.

Edit: you'll probably need to use IO::Socket::INET before replacing namespaces, too, so further calls to it won't eval it and overwrite Coro::Socket's subs back.


Comment on Re: Making Coro::Socket Override IO::Socket::INET
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2014-11-27 05:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (180 votes), past polls