#!/usr/bin/perl use strict; use warnings; use File::Find; my $globalerror=0; sub recDir { my $path=shift(@_); find(sub{ my $file=$File::Find::name; if($file=~/\.d$/) { if(open(my $fh, '<', $file)) { local $/=undef; print <$fh>; close($fh); } else { warn "Can't open $file ($!)\n"; $globalerror = 1; } } },$path); } recDir($ARGV[0]);