Hi,

 

Could you help me to find what's wrong in my script?

 

I need to compare two directories and if file exists in both - print it.

 

die "Usage: 2 arguments must be passed i.e. file1 file2\n" if @ARGV != 2;
opendir DIR1, $ARGV[0] or die "couldn't open $ARGV[0] for reading.\n";
opendir DIR2, $ARGV[1] or die "couldn't open $ARGV[1] for reading.\n";

foreach $filename(readdir DIR1) {
   next if $filename =~/^\./;
     while (readdir DIR2){
       if (-e $filename){
       print "$filename\n"}
     }
 }
closedir(DIR1);
closedir(DIR2);

 

Looks like I'm checking "if exists" in first directory but not in second.

 

-Vladimir

Reply via email to