I have a lot of legacy code which shells out a lot, what i want to do is add a require
or minimal code changes to make the backticks do something different, for instance print instead of running code
i tried using use subs
but i couldn't get it to take over backticks or qx (i did redefine system which is one less thing to worry about)
i also tried to make a package:
package thingmbob;
use Data::Dumper;
use overload '``' => sub { CORE::print "things!:\t", Dumper \@_};
#this works for some reason
$thingmbob::{'(``'}('ls');
#this does the standard backtick operation
`ls`
unfourtunatly, I have no experience in OOP perl and my google-fu skills are failing me, could some one point me in the right direction?
caveat: I'm in a closed system with a few cpan modules preinstalled, odds are that i don't have any fancy modules preinstalled and i absolutely cannot get new ones
I'm on perl5.14
edit:
for the sake of completeness i want to add my (mostly) final product
BEGIN {
*CORE::GLOBAL::readpipe = sub {
print Dumper(\@_);
@internal = readpipe(@_);
if(wantarray){
return @internal;
}else{
return join('',@internal);
}
};
}
I want it to print what its about to run and then run it. the wantarray
is important because without it scalar context does not work