in reply to vec and array parameters

I ran into the same thing with seek when writing this poem. If there is a reason you have an array instead of two separate variables for OFFSET and BITS, and you're going to call it a lot, you can write a wrapper like I did:
sub my_vec { vec($_[0],$_[1],$_[2] }
or just call it like vec($vec, $params[0], $params[1]).

The PerlMonk tr/// Advocate

Replies are listed 'Best First'.
Re: Re: vec and array parameters
by Thelonius (Priest) on Jan 07, 2004 at 17:09 UTC
    I thought of that too, but if you try to use my_vec on the left side of an assignment, you get:
    Can't modify non-lvalue subroutine call at testvec.pl line 10.

      Oh, then just make your sub an lvalue sub like so:

      sub my_vec : lvalue { vec($_[0],$_[1],$_[2]) }

      Caveat scriptor, I didn't test this at all and I'm sure you need a modernish perl for it to work.