sub scanDir { print "scandir() aufgerufen! \n"; # open current directory local *CURDIR; opendir(CURDIR, ".") or die "could not open directory $! \n"; # iterate over directory entries while(my $dirEntry = ) { # skip "." and ".." if($dirEntry eq "." || $dirEntry eq "..") { print "skipping . and ..! \n"; next; } # if we encounter a audio-file if(-f $dirEntry && $dirEntry =~ m/(.*mp3$)|(.*ogg$)/) { print "renaming file! \n"; renFile($dirEntry); } # if we encounter a directory, descend into it and start recursion elsif(-d $dirEntry) { chdir($dirEntry) or die "could not open directory $dirEntry! \n"; print "descend into next directory! \n"; scanDir(); } } close(CURDIR); return 0; }