I need to redefine localy one subroutine and have it correctlly after.
Who do I do it?

sub myPrint () {
    print "Teste 1\n";
}

sub test {
    no strict "refs";
    no warnings;
    
    my $str = "::myPrint";

#    my $backup = $main::{myPrint};
    my $backup = *$str;

    *$str = sub() {
        print "Teste 2\n";    
    };
    
    myPrint;
    
    *$str = $backup;
}

myPrint;
test;
myPrint;
exit;

Note: This is not beautyfull but I'm doing some test-cases and I don't
want to change the code to be tested.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to