use v5.12; use warnings; package MyModule; # This is the override for the select built-in. # use subs 'select'; sub select { my ($fh) = @_; warn "inside my custom select\n"; CORE::select($fh); } # Here's the select function we're going to expose to outside # code. # require namespace::clean; namespace::clean->clean_subroutines(__PACKAGE__, 'select'); no strict 'refs'; *{'select'} = sub { # Note that we can use the select override even within # this sub!! select *STDERR; print "Hello to STDERR!\n"; select *STDOUT; }; 1;