Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^3: override CORE sub and keep method in same package (Updated)

by BrowserUk (Pope)
on Oct 15, 2013 at 02:20 UTC ( #1058227=note: print w/replies, xml ) Need Help??


in reply to Re^2: override CORE sub and keep method in same package
in thread override CORE sub and keep method in same package

Update: I assuming from your typically terse description that you goal is to override the function of the built-in select only within the IO::Select module without overriding the select method it presents to its callers.

If that is not the case, perhaps you could clarify your requirements?

Yes. "CORE::GLOBAL::" is too aggressive.

Hm. The CORE::GLOBAL discussion is only a one part of the discussion referenced.

There is also use REGlob 'glob';            # override glob() in Foo:: only, amongst others.

But, to answer your specific problem, I'd suggest adding:

sub yourSelect { ... } sub select { local *CORE::GLOBAL::select = *yourSelect; shift if defined $_[0] && !ref($_[0]); my($r,$w,$e,$t) = @_; my @result = (); my $rb = defined $r ? $r->[VEC_BITS] : undef; my $wb = defined $w ? $w->[VEC_BITS] : undef; my $eb = defined $e ? $e->[VEC_BITS] : undef; if(select($rb,$wb,$eb,$t) > 0) ################################################ }

Wherever select is used in IO::Select. Make it conditional if appropriate.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^4: override CORE sub and keep method in same package (Updated)
by bulk88 (Priest) on Oct 15, 2013 at 14:53 UTC
    You guessed right. Unfortunately I have to change something in the existing method subs, for all the solutions presented here. So I might as well just replace all calls to builtin select in each method with a select2 I defined. Checking if the first arg is blessed is another solution which probably would have been cleaner then putting select2 everywhere.
      So I might as well just replace all calls to builtin select in each method with a select2 I defined.

      Yes. That is much simpler isn't it :)


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1058227]
help
Chatterbox?
[Corion]: marto: Great! The German Perl Workshop was a success even though things looked dire before, and I'm now back at home with two days off work still to go ;)
[Corion]: I hope things have settled down a bit for you and the boys are alright?!

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2017-06-29 08:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (655 votes). Check out past polls.