in reply to Passing file names to search directories

This code has many issues!

For a start, try renaming  my @fnames = shift; to  my $fnames = shift; (untested)

you should inform yourself about the differences between plain @arrays and $array_references.

And please remove the pod block, it's not a good approach to uncomment code.

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

Replies are listed 'Best First'.
Re^2: Passing file names to search directories
by Anonymous Monk on Dec 28, 2016 at 18:44 UTC
    I am sorry, here is a better sample of what I meant:
    #!/usr/bin/perl use strict; use warnings; use File::Find qw(finddepth); use File::Find qw(find); ... my ($dir,$datanames); # These var(s) has values been passed to the sub my $res_files = list_dirs($dir,$datanames); sub list_dirs { my @locations = shift; my $fnames = shift; my @files; find( { wanted => sub { push @files, $_ unless $_ eq '.' || $_ eq '..' +|| $_ !~ m/@$fnames->[0]{filename}$/} , no_chdir => 1 }, @locations); print Dumper \@files; return \@files; } # This is after DUMP of the data. =code my @locations = [ '/var/www/allfiles' ]; my $fnames = [ { 'filename' => 'abc122.txt' }, { 'filename' => '333twom.txt' }, { 'filename' => '56test.txt' }, { 'filename' => 't445ok.txt' } ]; =cut