*mysub = sub : prototype(\@\@) ($left,$right) { ... };
####
use strict;
use warnings;
no warnings 'experimental::signatures';
use feature qw/say signatures/;
use List::Util qw(all);
BEGIN {
( *array_numeq,*array_streq )
= map {
my $compare = $_;
sub :prototype(\@\@) ($l,$r) {
@$l == @$r &&
all { $compare->($l->[$_],$r->[$_]) } 0 .. $#$l
}
} sub { shift == shift }, sub { shift eq shift }
}
my @left = ( 1, 2, 3 );
my @right = ( 1, 2, 3 );
{
local $" = ',';
say "(@left) ",
( array_numeq @left, @right ) ? "matches" : "doesn't match",
" (@right)";
}
####
Array found where operator expected at mytest2.pl line 14, at end of line
(Missing operator before ?)
syntax error at mytest2.pl line 14, near "@\@) "
Global symbol "$l" requires explicit package name at mytest2.pl line 14.
Global symbol "$r" requires explicit package name at mytest2.pl line 14.
Global symbol "$l" requires explicit package name at mytest2.pl line 15.
Global symbol "$r" requires explicit package name at mytest2.pl line 15.
Global symbol "$l" requires explicit package name at mytest2.pl line 16.
Global symbol "$r" requires explicit package name at mytest2.pl line 16.
Global symbol "$l" requires explicit package name at mytest2.pl line 17.
BEGIN not safe after errors--compilation aborted at mytest2.pl line 17.
####
use strict;
use warnings;
no warnings 'experimental::signatures';
use feature qw/say signatures/;
use List::Util qw(all);
BEGIN {
( *array_numeq,*array_streq )
= map {
my $compare = $_;
+ sub :prototype(\@\@) ($l,$r) {
@$l == @$r &&
all { $compare->($l->[$_],$r->[$_]) } 0 .. $#$l
}
} sub { shift == shift }, sub { shift eq shift }
}
my @left = ( 1, 2, 3 );
my @right = ( 1, 2, 3 );
{
local $" = ',';
say "(@left) ",
( array_numeq @left, @right ) ? "matches" : "doesn't match",
" (@right)";
}
####
my $subref = do{
sub : prototype($) ($s) { return $s; }; # Perl thinks sub: is a label here.
};