By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,834 Members | 2,234 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,834 IT Pros & Developers. It's quick & easy.

Bad file descriptor

P: 30
Hi, everyone

I met a "Bad file descriptor" problem, and I test my var, it is right in the proceeding. I dont know why, any suggestion is helpful

[
Expand|Select|Wrap|Line Numbers
  1. $dir = "d:/1";
  2. #print "Text files in $dir are:\n";
  3. opendir(HANDLE, $dir) or die "Can't open $dir: $!";
  4. while( defined ($file = readdir HANDLE) ) 
  5. {
  6.     next if $file =~ /^\./;
  7.  
  8.     $dir2=$dir."/".$file;
  9.  
  10.     &removedir($dir2);   
  11. }
  12. closedir(HANDLE);
  13.  
  14. sub removedir
  15. {
  16.  
  17.     opendir(HANDLE2,$_[0]) or die $!;
  18.     #print "$_[0]\n";
  19.     while(defined ($file2=readdir HANDEL2) or die $!)
  20.     {
  21.         print "$_[0]/$file2\n";
  22.         next if $file2=~ /^\./;
  23.         if(-d "$_[0]/$file2")
  24.         {
  25.  
  26.             $_[0].="/".$file2;
  27.             &removedir($_[0]);
  28.  
  29.         }
  30.         unlink "$_[0]/$file2";
  31.  
  32.     }
  33.     closedir(HANDLE2);
  34.     rmdir $_[0] ;
  35.  
  36. }
"while(defined ($file2=readdir HANDEL2) or die $!)" <------ "bad file descriptor" died out here.

Thanks in advance.
Oct 8 '08 #1
Share this Question
Share on Google+
3 Replies


KevinADC
Expert 2.5K+
P: 4,059
look at how you have HANDEL2 spelled
Oct 8 '08 #2

P: 30
look at how you have HANDEL2 spelled
I'm sorry for inattention.

Thank you, Kevin.
Oct 8 '08 #3

KevinADC
Expert 2.5K+
P: 4,059
I'm sorry for inattention.

Thank you, Kevin.
We've all done it. Glad it was an easy one.
Oct 8 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.