Home > Archive > PERL Miscellaneous > June 2007 > Re: Passing function references in the constructor
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: Passing function references in the constructor
|
|
| koszalekopalek@interia.pl 2007-06-26, 8:03 am |
| On Jun 25, 12:46 am, Michele Dondi <bik.m...@tiscalinet.it> wrote:
(...)
> But you probably meant just
>
> fun => \&mypack::test1
Thanks to everybody that answered.
Now I understand better what's going on.
I think replacing
fun => sub { mypack::test1 (@_) }
with
fun => \&mypack::test1
is what I was looking for. (I tried that with
the arrow syntax
fun \&mypack->test1
but that gave me the following error:
Backslash found where operator expected at a.pl line 46, near "fun \"
I always (well, almost) use strict - the example I
posted was a chopped down version of what I was
trying to achieve.
> After much thinking... I suspect smell of XY problem here. See e.g.
> <http://perlmonks.org/?node=XY+problem>.
Well, that may be true - I think I have some problems
figuring out what should be enclosed in the class and
what should not.
Thanks again,
K.O.
>
> Michele
> --
> {$_=pack'B8'x25,unpack'A8'x32,$a^=sub{po
p^pop}->(map substr
> (($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
> .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
> 256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
| |
| Michele Dondi 2007-06-26, 8:03 am |
| On Mon, 25 Jun 2007 22:51:47 -0700, koszalekopalek@interia.pl wrote:
>I think replacing
> fun => sub { mypack::test1 (@_) }
>with
> fun => \&mypack::test1
In fact with that bacslash in front, &mypack::test1 is fundamentally
nothing but a name, which means you're taking a reference to the sub
it refers to.
>is what I was looking for. (I tried that with
>the arrow syntax
> fun \&mypack->test1
>but that gave me the following error:
> Backslash found where operator expected at a.pl line 46, near "fun \"
Missing C< => >?
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{po
p^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
|
|
|
|
|