Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^4: how to rm an element from an array?

by tobyink (Canon)
on Feb 27, 2020 at 23:30 UTC ( #11113526=note: print w/replies, xml ) Need Help??


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

Slightly different, but I quite like this:

sub yoink (&\@) { @{$_[1]} = grep !$_[0]->($_), @{$_[1]} } my @arr = qw( aa bb cc ); yoink { $_ eq 'bb' } @arr; print "@arr\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11113526]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2021-01-26 12:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?