http://qs321.pair.com?node_id=208439


in reply to Re^2: how to rm an element from an array?
in thread how to rm an element from an array?

If you always want to modify the original array, you could use function prototypes (let the scolding begin!) and use yoink like a builtin. That way, you wouldn't have to keep passing \@arr as a ref like that. However, if you want to keep the original array intact and let yoink return a separate copy with the proper yoinkage, then this is certainly not at all what you want.
sub yoink(\@$) { my ($array_ref, $remove) = @_; @$array_ref = grep { $_ ne $remove } @$array_ref; } my @arr = qw/un deux trois quatre cinq six sept huit/; # no passing of \@arr -- oh, so pretty! yoink @arr, 'deux'; print "@arr\n"; __END__ un trois quatre cinq six sept huit

blokhead