<?xml version="1.0" encoding="windows-1252"?>
<node id="1017931" title="Re: Redefining Imported Subs: of scope and no" created="2013-02-09 00:50:43" updated="2013-02-09 00:50:43">
<type id="11">
note</type>
<author id="805072">
7stud</author>
<data>
<field name="doctext">
&lt;i&gt;&lt;p&gt;Let's try something new; how about manually deleting/redefining the subroutine in the symbol table?&lt;/p&gt;&lt;code&gt;

use feature 'say';
undef &amp;say;
*say = \&amp;not_say;
say 'test';
sub not_say {
    print 'not saying';
}
&lt;/code&gt;&lt;p&gt;
Maybe I'm getting my namespaces all mixed up because that doesn't seem to redefine the sub at all.&lt;/p&gt;&lt;/i&gt;
&lt;p&gt;The confounding thing is that this works:&lt;/p&gt;
&lt;code&gt;

use strict;
use warnings;
use 5.012;

#Rule: sub names are entered into the symbol table.
sub abc {
    print "abc\n";
}

sub xyz {
    print "xyz\n";
}

local *abc; #gets rid of 'redefined main::abc' warning'
*abc = \&amp;xyz;
abc;

--output:--
xyz
&lt;/code&gt;
&lt;p&gt;But this doesn't work:&lt;/p&gt;
&lt;code&gt;

use strict;
use warnings;
use 5.012;

sub xyz {
    print "xyz\n";
}

local *say;
*say = \&amp;xyz;
say 'hello';

--output:--
hello
&lt;/code&gt;&lt;p&gt;
Nor does this:&lt;/p&gt;
&lt;code&gt;
use strict;
use warnings;
use 5.012;

use subs qw( say );  #Supposedly overrides a built in

my $verbose = 1;

sub say {
    if ($verbose) {
        print shift, " world\n";
    }
}

say 'hello';

--output:--
hello
&lt;/code&gt;

</field>
<field name="root_node">
1017898</field>
<field name="parent_node">
1017898</field>
</data>
</node>
