in reply to Grepping for a value in a hash of filenames and printing the matches
$Hash_filenames{$plf}=@file_lines;
An array evaluated in scalar context returns the number of elements it contains.
A hash element is a scalar. It cannot contain an array. It can contain a reference to an array.
Fix:
my @file_lines = <$match>; $Hash_filenames{$plf} = \@file_lines;
or
$Hash_filenames{$plf} = [ <$match> ];
$Hash_filematches{$filename}= grep( /\/\Q$file_name\E#/i, $Hash_filenames{$plf} );
Fix for the first two:
$Hash_filematches{$filename} = [ grep( /\/\Q$file_name\E#/i, @{ $Hash_filenames{$plf} } ) ];
Sorry, I don't have time to understand what you are trying to do in order to propose a solution for the third item. But maybe knowing what the problem is will help you.
|
|---|