<?xml version="1.0" encoding="windows-1252"?>
<node id="1006894" title="Re: change perl function in runtime" created="2012-12-03 10:19:37" updated="2012-12-03 10:19:37">
<type id="11">
note</type>
<author id="708738">
LanX</author>
<data>
<field name="doctext">
You need *globs to manipulate symbol table entries like package functions! ( see [doc://perlmod] and [doc://perlsub])&lt;P&gt;

Something like this should do&lt;P&gt;

&lt;c&gt;
{
  package A;
  local *x = sub { die "aaa" };
 
  #run tests
  ...
}
# &amp;x reset after leaving block
&lt;/c&gt;&lt;P&gt;



if you want to explicitly reset &lt;c&gt;&amp;x&lt;/c&gt; try to store the old coderef before. &lt;P&gt;

&lt;c&gt;
$old_coderef = \&amp;x;
 
# run tests
... # do what you want 
... # (but think about the omen ;-)
 
*x = $old_coderef;
&lt;/c&gt;&lt;P&gt;

&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-708738"&gt;
&lt;p&gt;Cheers Rolf
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
1006889</field>
<field name="parent_node">
1006889</field>
</data>
</node>
