Link to home
Start Free TrialLog in
Avatar of Handschuh
Handschuh

asked on

error in a subroutine

I write a Perl-script for Win32.
One of the subroutines has a mistake.

sub dateianzahl{
my $zaehler;
my $arg;

$arg=$_[0];
$zaehler=0;
foreach $arg(@arg){
 if (-d $arg){
     opendir D, $arg;
     push @arg, map{$arg.'/'.$_}
      grep {!/^(\.|\.\.)$/}readdir(D);
      closedir(d);
 if(-f $arg){
    open F, $arg;
    @l=<F>;
    close F;
    $zaehler++;
     @l=();}
 return $zaehler;}}

The subroutine is called by example
dateianzahl(c:\\u1\\hl7\\work\\ok);

What´s wrong!
Thank you for you help!
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of olthoff
olthoff

You also
opendir D $arg

but
closedir d;

I am not sure how perl handles opening another dir without closing the first one.  The d should be capitalized on the closedir...
Do you require any furthur help?