in reply to Limit number of Sub routine argument list
Maybe like this? (You didn't say what is supposed to happen if there are more than a certain number of arguments, i.e. ignore, warn, die,... at runtime or compile-time...)
#!/usr/bin/perl sub foo { $#_ = 3 if @_ > 3; # limit to 4 args print "$_\n" for @_; print "---\n"; } foo(1,2,3); foo(1,2,3,4); foo(1,2,3,4,5); __END__ 1 2 3 --- 1 2 3 4 --- 1 2 3 4 ---
(obviously, what I've shown implements the 'ignore' variant)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Limit number of Sub routine argument list
by Anonymous Monk on Oct 25, 2009 at 09:42 UTC |