error in a subroutine

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

sub dateianzahl{
my $zaehler;
my $arg;

foreach $arg(@arg){
 if (-d $arg){
     opendir D, $arg;
     push @arg, map{$arg.'/'.$_}
      grep {!/^(\.|\.\.)$/}readdir(D);
 if(-f $arg){
    open F, $arg;
    close F;
 return $zaehler;}}

The subroutine is called by example

What´s wrong!
Thank you for you help!
Who is Participating?
ozoConnect With a Mentor Commented:
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.

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,
You also
opendir D $arg

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?
All Courses

From novice to tech pro — start learning today.