in reply to Re^3: Unforgettable Closures? (shave)
in thread Unforgettable Closures?
(shave)hehe. Yeah, Occams Razor because of my mistaken assumptions (closure funkiness versus perlsyn (my) funkiness). Me:
Thanks, that clears it up, I guess. I've not got anything newer than Perl 5.8.8, and grepping perlsyn for the said gotcha finds nothing, so I'm assuming I need a newer Perl?I meant new version of Perl for which the man page for perlsyn mentions the "my" strangeness. I ought to have mentioned it, but before I'd reproduced the funkiness on my local 5.8.8 installation, I came across it on (sigh) 5.6.1 - on which the following fix worked:
Well whatever the reason is, the fix was simply:Of course, as you rightly point out, separating the "my" and the conditional also works, like you point out.#my $func = shift if ref $_[0] eq 'CODE'; my $func = ref $_[0] eq 'CODE' ? shift() : undef;
all good! Thanks.my $func; $func = shift if ref $_[0] eq 'CODE';
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Unforgettable Closures? (shave)
by ikegami (Patriarch) on Dec 10, 2007 at 05:59 UTC | |
by faiz (Acolyte) on Dec 10, 2007 at 07:27 UTC | |
|
Re^5: Unforgettable Closures? (shave)
by tye (Sage) on Dec 10, 2007 at 05:52 UTC |