in reply to Returning multiple values from subroutine
Below second statement says give me 1st and 6th things in list. Normally I put the left hand parms in the order that program is going to use them and adjust the slice list according, ie [5,0], [8,1..3,0], [0,-1] are all valid slices. -1 means last thing in list, -2 would be next to last thing in list. The main limitation is that a range cannot go backwards, 0..3 is ok, but 3..0 is not.
Upate: a small point, I wouldn't use -1 in slice list here, using the absolute value of 5 allows more parms to be added without affecting existing code. But here is an example where -1 works GREAT!my ($locked,undef,undef,undef,undef,$expire)=$ssh->get_user_info($logi +nid); my ($locked,$expire) = ($ssh->get_user_info($loginid))[0,5];
Note that works even if there is only one thing in @something! It is ok for the last thing in the list to be the only thing in the list.my ($min,$max) = (sort @something)[0,-1];
|
|---|