#!/usr/bin/perl use strict; use warnings; my $globalerror=0; sub recDir { my $path=shift(@_); if (opendir (my $DIR, $path)) { my @files=readdir($DIR); closedir($DIR); for my $file (@files) { # . und .. überspringen next if($file eq '.' or $file eq '..'); # pfad konstruieren my $new_path="$path/$file"; # wenn Datei und Endung ".d" if(-f $new_path and $file=~/\.d$/) { # Datei öffnen und ausgeben if(open(my $fh, '<', $new_path)) { local $/=undef; print <$fh>; close($fh); } else { warn "Can't open $new_path ($!)\n"; $globalerror = 1; } } recDir($new_path) if (-d $new_path); } } else { warn "can't open Dir $path ($!)\n"; $globalerror = 1; } } recDir($ARGV[0]);