Thank you.  The useful note about CORE, in particular, is new to me.

cts

--- On Sun, 6/24/12, Rob Dixon <rob.di...@gmx.com> wrote:

> From: Rob Dixon <rob.di...@gmx.com>
> Subject: Re: how to do a reference to a func in Math::Trig
> To: "Perl Beginners" <beginners@perl.org>
> Cc: "Charles Smith" <cts.priv...@yahoo.com>
> Date: Sunday, June 24, 2012, 11:53 AM
> On 24/06/2012 19:51, Rob Dixon
> wrote:
> > 
> > or by aliasing the current package's 'sin' and 'cos'
> subroutines with
> > the CORE functions:
> > 
> >      use strict;
> >      use warnings;
> > 
> >      use Math::Trig;
> > 
> >      BEGIN {
> >        no warnings 'once';
> >        *sin = \&CORE::sin;
> >        *cos = \&CORE::cos;
> >      }
> > 
> >      for my $func (qw/ sin cos tan /) {
> >        my $f = \&$func;
> >        print $f->(pi/4), "\n";
> >      }
> > 
> > which IMO is the tidiest, and certainly the most
> efficient.
> 
> Please note that the 'no warnings' is necessary only for
> runtime typeglob assignments. This also works fine, and is
> even neater.
> 
>     use strict;
>     use warnings;
> 
>     use Math::Trig;
> 
>     BEGIN {
>       *sin = \&CORE::sin;
>       *cos = \&CORE::cos;
>     }
> 
>     for my $func (qw/ sin cos tan /) {
>       my $f = \&$func;
>       print $f->(pi/4), "\n";
>     }
> 
> -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
> 
> 
>

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to