On 8/3/05, John W. Krahn <[EMAIL PROTECTED]> wrote:
> marcos rebelo wrote:
> > I need to redefine localy one subroutine and have it correctlly after.
> > How do I do it?
>
> $ perl -e'
> my $myPrint = sub { print "Teste 1\n" };
>
> sub test { $myPrint = sub { print "Teste 2\n" } }
>
> $myPrint->
marcos rebelo wrote:
> 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};
sub myPrint () {
print "Teste 1\n";
}
sub test() {
no strict "refs";
no warnings;
my $subName = "::myPrint";
my $backup = \&myPrint;
*$subName = sub() {
print "Teste 2\n";
};
myPrint;
*$subName = $backup;
}
myPrint;
test;
myPrint;
On