468,321 Members | 1,761 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,321 developers. It's quick & easy.

Bad file descriptor

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
3 8859
KevinADC
4,059 Expert 2GB
look at how you have HANDEL2 spelled
Oct 8 '08 #2
anklos
30
look at how you have HANDEL2 spelled
I'm sorry for inattention.

Thank you, Kevin.
Oct 8 '08 #3
KevinADC
4,059 Expert 2GB
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.

Similar topics

6 posts views Thread by Siddharth Taneja | last post: by
3 posts views Thread by gipsy boy | last post: by
7 posts views Thread by news | last post: by
4 posts views Thread by darrin.skinner | last post: by
3 posts views Thread by akaarj | last post: by
5 posts views Thread by yinglcs | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by howard w | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.