On Jul 5, [EMAIL PROTECTED] said:

>I need to redefine a subroutine from one package to a subroutine from
>another.
>
>This code works and does what I want it to, however I need to write it so
>it isn't hard coded. The posible necessary escapes, evals, single quotes
>and double quotes make me woozy.
>
>    ##### WORKS !!!! #####
>       undef &Default_DB::special_code ;
>       *DatabaseLib::special_code    = \&Sybase_DB::special_code ;

You want to do symbolic reference work.  This is one of the only times you
should use them.

  {
    no strict 'refs';  # in case that's on, which it should be
    my $old_func = 'Old::Function';
    my $new_func = 'New::Func';

    *$old_func = \&$new_func;
  }

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk?  http://www.perlmonks.com/     http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc.     http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter.         Brother #734
**      Manning Publications, Co, is publishing my Perl Regex book      **

Reply via email to