http://www.perlmonks.org?node_id=1029148


in reply to Re: Require input reading files recursively in perl
in thread Require input reading files recursively in perl

Thanks a lot. Below is the newer version and it works fine. Appreciate the time and your valuable input.
#!/usr/bin/perl use strict; use warnings; my $parent_dir = "/panther/home/efxprod/support"; process_dir($parent_dir); sub process_dir { my $dir = shift; print "Processing $dir\n"; opendir(my $SCR , $dir) or die "Can't open $dir: $!"; while( defined (my $file = readdir $SCR) ) { next if ($file =~ /\.$/ ); next if ($file =~ /\.txt$/ ); if ( $file =~ /\.sh$/ ) { print "not a regullar file: $file\n"; } elsif ( $file =~ /\.pl$/) { print "perl $file\n"; } elsif ( -d "$dir/$file" ) { print "directory : $dir/$file\n"; process_dir("$dir/$file/"); #next; #} elsif ( $file } else { print "Else :$file\n" if ( -B "$dir/$file"); } print "file -> $file\n"; } closedir($SCR); }