in reply to Re: Fighting sub foo($;$$)
in thread Fighting sub foo($;$$)
Why don't you just remove the prototype?
I'd be careful with that, OP says this is legacy code, and simply removing the prototype could change how the code behaves at call sites that the OP doesn't want to affect. The $ prototype doesn't just mean "accept one argument", it also means "force scalar context on this argument".
my @ary = ("a","b","c"); sub foo($;$$) { print Dumper(\@_) } sub foo2 { print Dumper(\@_) } foo (@ary, ("x","y"), "z"); # @_ is [3, 'y', 'z' ] foo2(@ary, ("x","y"), "z"); # @_ is ['a', 'b', 'c', 'x', 'y', 'z']
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Fighting sub foo($;$$)
by LanX (Saint) on Apr 14, 2023 at 21:47 UTC |