in reply to Getting a list of aliases to selected items from a list of array references
You could do (untested, and probably some experimentation needed to find a good cutoff point):and that lead me to realize that I could get what I want using eval: eval "&\$sub( " . join( ", ", map "\$_[$_][0]", 0..$#_ ) . " )"if( 0 == @_ ) { &$sub(); } elsif( 1 == @_ ) { &$sub( $_[0][0] ); } elsif( 2 == @_ ) { &$sub( $_[0][0], $_[1][0] ); } elsif( 3 == @_ ) { &$sub( $_[0][0], $_[1][0], $_[2][0] ); # etc to some arbitrary maximum number of arguments }
if ($#_ <= 255) { my $lim = $#_; &$sub(($_[0][0],$_[1][0],$_[2][0],$_[3][0],$_[4][0], $_[5][0],$_[6][0],$_[7][0],$_[8][0],$_[9][0], ... $_[255] )[0..$lim]); $#_ = $lim # remove autovivified arrayrefs } else { eval "&\$sub( " . join( ", ", map "\$_[$_][0]", 0..$#_ ) . " )"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Getting a list of aliases to selected items from a list of array references (unroll)
by tye (Sage) on May 17, 2004 at 03:06 UTC | |
by antirice (Priest) on May 18, 2004 at 13:27 UTC |