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\\w ork\\ok);
What´s wrong!
Thank you for you help!
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\\w
What´s wrong!
Thank you for you help!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Do you require any furthur help?
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...