The push operator can take a list in the second argument. What you want is a slice of @old_array:
That checks the size of @old_array to see if it has at least $count elements. If less or equal, the whole array is pushed without padding, otherwise the slice of the first $count elements is pushed.push @new_array, $count > @old_array ? @old__array : @old_array[0 .. $count-1];
After Compline,
Zaxo
In reply to Re: range operators
by Zaxo
in thread range operators
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |