in reply to Re^3: Can @_ be extended?
in thread Can @_ be extended?

I note that this: ... works as well.

Yep. Though I would write that as:

sub setmode ($\@) { our( $val, @array ); local( $val,*array ) = @_; splice (@array, 1, 0, $val); }

Ie. Order the values in the our to match the prototype, and localise the globals so that when you call this function from another that also uses one of the globals $val or @array, you don't stomp on their values by mistake.

There are various aiasing packages on CPAN, but they mostly (all?) only allow you to alias similar types, which is different to aliasing a array name for an array ref as we are doing here.


Examine what is said, not who speaks.
Silence betokens consent.
Love the truth but pardon error.