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!
HandschuhAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
Name "main::d" used only once: possible typo at - line 12 (#2)
   
    (W) Typographical errors often show up as unique variable names.
    If you had a good reason for having a unique name, then just mention
    it again somehow to suppress the message.  The use vars pragma is
    provided for just this purpose.

dateianzahl(c:\\u1\\hl7\\work\\ok);
Unquoted string "c" may clash with future reserved word at - line 19 (#1)
syntax error at - line 19, near "c:"

Backslash found where operator expected at - line 19, near "u1\" (#2)
   
    (S) The Perl lexer knows whether to expect a term or an operator.  If it
    sees what it knows to be a term when it was expecting to see an operator,
    it gives you this warning.  Usually it indicates that an operator or
    delimiter was omitted, such as a semicolon.
   
Also, you seem to be changing @arg inside of a loop on @arg,
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
olthoffCommented:
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...
0
ozoCommented:
Do you require any furthur help?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.