You can try this:
I modified your OP using your description below:
Usage:your_perl_script.pl directory_to_be_checked indexDS.txt > output_file.txtuse warnings; use strict; use Cwd qw(abs_path); die "Please give the directory to the file on CLI" unless @ARGV == 2; my ( $dir, $file_to_reference ) = @ARGV; my @ds; open my $fh, '<', $file_to_reference or die "can't open file: $!"; while (<$fh>) { chomp; push @ds, $_; } close $fh or die "can't close file: $!"; $dir = abs_path($dir); chdir $dir or die "No such directory: $!"; my @result; opendir my $dh, $dir or die "can't open dir: $!"; while ( my $file = readdir $dh ) { for (@ds) { push @result, $_ if $_ eq $file; } } closedir $dh or die "can't close directory: $!"; print $_, $/ for @result;
In reply to Re: Looking up elements of an array in another array!
by 2teez
in thread Looking up elements of an array in another array!
by better
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |