I would like to use the grep function to filter the list of values ββand store the link to the filtered list in a hash. What I need is something like:
my $allValues = [ 'a', 'unwanted value', 'b', 'c', ]; $stuff = { 'values' => grep { $_ ne 'unwanted value' } @$allValues };
Only when I try to do this, hash %$stuff :
$ VAR1 = {
'b' => 'c',
'values' => 'a'
};
Is there a way to fix the anonymous hash code so that I get:
$ VAR1 = {
'values' => [
'a',
'b',
'c'
]
};
But not by creating a local variable or calling a subroutine (in other words, everything on the line)?
source share