in reply to Search & Replace in an Array
A generic form for a generic question:
The above can also be written asfor (@array) { if (condition($_)) { $_ = transform($_); } }
For example,$_ = transform($_) for grep condition($_), @array;
my @array = qw( John Jake and Jasper ); $_ = uc($_) for grep /^a/, @array; print("@array\n"); # John Jake AND Jasper
|
|---|