Как я могу отфильтровать массив без использования цикла в Perl?

Здесь я пытаюсь отфильтровать только те элементы, которые не имеют подстрокиworld и сохранить результаты обратно в тот же массив. Как правильно сделать это в Perl?

$ cat test.pl
use strict;
use warnings;

my @arr = ('hello 1', 'hello 2', 'hello 3', 'world1', 'hello 4', 'world2');

print "@arr\n";
@arr =~ v/world/;
print "@arr\n";

$ perl test.pl
Applying pattern match (m//) to @array will act on scalar(@array) at
test.pl line 7.
Applying pattern match (m//) to @array will act on scalar(@array) at
test.pl line 7.
syntax error at test.pl line 7, near "/;"
Execution of test.pl aborted due to compilation errors.
$

Я хочу передать массив в качестве аргумента подпрограмме.

Я знаю, что одним из способов было бы что-то вроде этого

$ cat test.pl 
use strict;
use warnings;

my @arr = ('hello 1', 'hello 2', 'hello 3', 'world1', 'hello 4', 'world2');
my @arrf;

print "@arr\n";

foreach(@arr) {
    unless ($_ =~ /world/i) {
       push (@arrf, $_); 
    }
}
print "@arrf\n";

$ perl test.pl
hello 1 hello 2 hello 3 world1 hello 4 world2
hello 1 hello 2 hello 3 hello 4
$

Я хочу знать, есть ли способ сделать это без цикла (используя некоторую простую фильтрацию).

Ответы на вопрос(4)

Ваш ответ на вопрос