Thank you. The useful note about CORE, in particular, is new to me.
cts
--- On Sun, 6/24/12, Rob Dixon wrote:
> From: Rob Dixon
> Subject: Re: how to do a reference to a func in Math::Trig
> To: "Perl Beginners"
> Cc: "Charles Smith"
> Date: Sunday, June
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;
}
f
On 24/06/2012 06:59, Charles Smith wrote:
Thank you, that was the clue I needed! This now works for me:
...
$f = $opts{f} || "sin";
...
$f = "Math::Complex::$f";
...
print eval ($amplitude) * (&$f (2 * pi * $i/$n) + eval ($dc))."\n";
and so I can use this, my "siggen" pgm wit
thank you.
cts
--- On Sat, 6/23/12, Ron Bergin wrote:
> From: Ron Bergin
> Subject: Re: how to do a reference to a func in Math::Trig
> To: "Charles Smith"
> Cc: beginners@perl.org
> Date: Saturday, June 23, 2012, 3:28 PM
> Charles Smith wrote:
>
> [snip]
Charles Smith wrote:
[snip]
>
> But this pgm fails:
>
> #!/usr/bin/env perl
> use Math::Trig;
> my $a = \&Math::Trig::cos;
> &$a(0);
>
> Undefined subroutine &Math::Trig::cos called at modfunctor line 7.
>
The cos sub is defined in Math::Complex, which Math::Trig loads.
Try this:
use strict;
us
Hello Shawn, thank you for answering.
I'm sorry, I was a bit sloppy with my example and so maybe unclear about my
question ...
It's not about the precise syntax of getting a reference to a subroutine, but
rather a subroutine in a module.
For example, this pgm is clear:
#!/usr/bin/env perl
sub
On 12-06-23 10:12 AM, Charles Smith wrote:
I'm experimenting with Math::Trig and would like to be able to pass the
function in as a parameter:
$f = $opts{f} || &sin;
$f = $opts{f} || \&sin;
See `perldoc perlreftut` and `perldoc perlref`.
--
Just my 0.0002 million dollars worth,
Hi,
I'm experimenting with Math::Trig and would like to be able to pass the
function in as a parameter:
$f = $opts{f} || &sin;
...
&$f($w);
Undefined subroutine &main::sin called at (eval
9)[/usr/lib/perl5/5.14.2/perl5db.pl:640] line 2.
I have also tried:
$f = &Math::Trig::sin;