LanX has asked for the wisdom of the Perl Monks concerning the following question:
Hi
I'm trying to write a core any (details here) but I'm having an unexpected bug.
Not my day today, could plz someone explain me whats wrong here?
DB<194> @a=1..5 => (1, 2, 3, 4, 5) DB<195> first {$_ eq 3 } @a => 3 DB<196> prototype \&List::Util::first => "&\@" DB<197> sub any (&\@) { &List::Util::first } DB<198> any {$_ eq 3 } @a => undef
It's a pure wrapper which should return the same results.
from perlsub
&NAME; # Makes current @_ visible to called subroutine.
SOLVED
Sorry I got bitten by escaping
DB<210> sub any (&\@) { &List::Util::first } DB<211> prototype \&any => "&\\\@" DB<212> sub any (&@) { &List::Util::first } Prototype mismatch: sub DB::any (&\@) vs (&@) at (eval 254)[multi_perl +5db.pl:2279] line 1. DB<213> prototype \&any => "&\@" DB<214> any {$_ eq 0 } @a => undef DB<215> @a => (1, 2, 3, 4, 5) DB<216> any {$_ eq 0 } @a => undef DB<217> any {$_ eq 5 } @a => 5
Cheers Rolf
( addicted to the Perl Programming Language)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Problem wrapping prototyped function [SOLVED]
by Laurent_R (Canon) on Dec 17, 2013 at 18:59 UTC | |
by LanX (Saint) on Dec 17, 2013 at 22:30 UTC | |
by Laurent_R (Canon) on Dec 18, 2013 at 19:58 UTC | |
Re: Problem wrapping prototyped function [SOLVED]
by hdb (Monsignor) on Dec 17, 2013 at 17:27 UTC |
Back to
Seekers of Perl Wisdom