No offense intended, but you could start by making the varible names a little more descriptive. Then use at least use strict, but it's only a suggestion. Now see inline comments
> -----Original Message----- > From: William Black [mailto:[EMAIL PROTECTED]] > Sent: Thursday, July 25, 2002 1:39 PM > To: [EMAIL PROTECTED] > Subject: re: little help > > > Can someone tell me why the below code can't won't work. > > Essentially, there is a directory full of files and I wanted > to compare them > to names I stored in a file. If the name of the file is not > found I just > want to say file not found, etc... > > A liitle help please.... > > $bin_dir = '.......'; > > > open(FILE,'ck') or die "Could not open file!!!!!" ; > $ct=0; > while(<FILE>){$tmp = $_;chomp($tmp); $array[$ct] = $tmp;$ct++;} #better written as: while(<FILE>){ chomp; push @array, $_; } > close(FILE); > > > chdir($bin_dir); > opendir(BINDIR,$bin_dir) or die "Could not open" $trillium=@array; # this looks like a typo. shouldn't it be: opendir(BINDIR,$bin_dir) or die "Could not open: $!"; # $! tells you why it died $trillium = @array; ## you really don't need this and you will see why. > $laurel = @binfiles; ## where did @binfiles come from???? > foreach $file(@binfiles){ ## shouldn't it be ## foreach $file (@array){ #???? ## or foreach $file (readdir BINDIR){ #??? print "$file was not found in ck.\n" unless grep $file eq $_, @array; } ## what the heck is this while loop? use grep (see above) > $marker=0; > $count=0; > while($count <= ($trillium-1)){ > if($file eq $array[$count]){ > $marker=1; > last; > } > > $count++; > }#while > > if($marker == 0){print"$file was not found\n";} > } > > > > > > William Black > > > > William Black > > > > _________________________________________________________________ > Send and receive Hotmail on your mobile device: http://mobile.msn.com > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > ---------------------------------------------------------------------------- -------------------- The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]