develooper Front page | perl.perl5.porters | Postings from October 2003

Not enough arguments

Thread Next
From:
Alexey Tourbin
Date:
October 30, 2003 11:47
Subject:
Not enough arguments
Message ID:
20031030194653.GJ1820@julia.office.altlinux.ru
Hi,

there's a problem (as for me) in how perl checks the number of arguments
for prototyped subroutines.  I've discovered this problem with a few
CPAN modules (we're setting nightly rebuild of our repo/distro, including
163 CPAN packages; perl checks are very strict).

In particular, slices do not work.  Should they?
The only way to pass a few arguments is to make a real list.
I can give real examples of this problem/error in CPAN packages.

$ perl -ce 'sub a($$$){} sub b {a(@_)}'
Not enough arguments for main::a at -e line 1, near "@_)"
-e had compilation errors.
$

$ perl -ce 'sub a($$$){} sub b {a(@_[0,1,2])}'
Not enough arguments for main::a at -e line 1, near "])"
-e had compilation errors.
$

$ perl -ce 'sub a($$$){} sub b {a($_[0],$_[1],$_[2])}'
-e syntax OK
$

$ perl -ce 'sub a($$$){} sub b {&a}'
-e syntax OK
$

-- 
Alexey Tourbin
ALT Linux Team

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About