in reply to open annoyance

The reason, of course, is Perl's prototyping behavior. Example:
sub proto ($@) { print "$_[0]; $_[1..$#_]\n"; } my @args = qw( a b c d e f ); proto($args[0], @args[1..$#args]); proto(@args[0..$#args]);
Perl applies scalar() to the first "argument" you pass proto() at compile-time. In this case, that's $args[0] and @args[0..$#args] -- in the former, there is no change, but in the latter, we end up getting the last element in the array! When you pass an array as the first element, it gets transmuted into its size. (But you probably knew most of this already.)

I've been in a similar situation. The simplest work-around I can think of is the one you've shown, where you separate the first element of the array from the others. Whether you do that destructively (as with shift) or with slices is a personal choice.


Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

Replies are listed 'Best First'.
Re^2: open annoyance
by tlm (Prior) on Sep 29, 2005 at 13:40 UTC

    Thanks. I could have saved myself a lot of hassle if I had just looked at the output of prototype( 'CORE::open' ). I'd mistakenly looked at prototype( 'open' ), which returned nothing, so I figured open was one of the builtin functions that doesn't have a prototype... :-/

    the lowliest monk