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


in reply to Re: How to read files in all subfolders?
in thread How to read files in all subfolders?

2teez,

I noticed a few things that could help the performance of your File::Find solution above.

In the search sub:

find( \&search_all_folder, $path ); sub search_all_folder { chomp $_; return if $_ eq '.' or $_ eq '..'; read_files($_) if (-f); }

In this function:

sub read_files { my ($filename) = @_; open my $fh, '<', $filename or die "can't open file: $!"; while (<$fh>) { print $_, $/; } }

And one question: what is the reason for using abs_path? I find that File::Find works fine with relative pathnames. Does it help the performance if an absolute pathname is given?