in reply to passing number of files in directory to subroutine

The bug was most likely the missing \ between the $dir and the $filenme. The following fixes that and is a little more Perlish than Cish:

use strict; use warnings; my ($dir1, $dir2, $testfile) = @ARGV; opendir DIR1, $dir1 or die "Can't open directory $dir1: $!\n"; opendir DIR2, $dir2 or die "Can't open directory $dir2: $!\n"; my @onedir = readdir(DIR1); my @twodir = readdir(DIR2); closedir DIR1; closedir DIR2; for my $onefile (@onedir) { my $twofile = shift @twodir; next if $onefile =~ /^\./; $onefile = "$dir1\\$onefile"; $twofile = "$dir2\\$twofile"; Calc($onefile, $twofile, $testfile); } sub Calc { my ($onefile, $twofile, $testfile) = @_; print "$onefile, $twofile, $testfile\n"; }

Perl is Huffman encoded by design.