I have a one array . I want the array to be such that it does not have any values of $regex (in a logical OR way). I am using grep command in a negation way, but I don't think this is solving my problem. Any help is highly appreciated. Thanks
#!/usr/bin/perl -w
use Data::Dumper;
my @array = ['hard_link is not present', 'dynamic variable', 'segfault'] ;
my $regex = qr/create_hard_link|Failed to reassign|Global variable/ ;
print Dumper(\@array) ;
my @wanted_array = grep {!$regex} @array ;
print Dumper(\@wanted_array);
it gives me an output as
$VAR1 = [
[
'hard_link is not present',
'dynamic variable',
'segfault'
]
];
$VAR1 = [];
[ ... ]creates an array reference. You want@array = ( ... ). So@array = [ ... ]creates that arrayref and assigns it to the first element of@array. I figure that this isn't what you want.