Y
yihucd
I wish to be able to find all .txt files in a dir recursively using
perl script, can anyone tell me how to write this perl script?
perl script, can anyone tell me how to write this perl script?
I wish to be able to find all .txt files in a dir recursively using
perl script, can anyone tell me how to write this perl script?
I wish to be able to find all .txt files in a dir recursively using
perl script, can anyone tell me how to write this perl script?
I wish to be able to find all .txt files in a dir recursively using
perl script, can anyone tell me how to write this perl script?
I wish to be able to find all .txt files in a dir recursively using
perl script, can anyone tell me how to write this perl script?
perldoc readdir
I wish to be able to find all .txt files in a dir recursively using
perl script, can anyone tell me how to write this perl script?
(Well, Boys & Girls, it's time for yet another message from
DavidFilmer on the wonders of the module IO::All.
Dr.Ruud:
I wouldn't.
I wouldn't use a perl script to do this -- there's a tool specially
written to do this kind of stuff, and it's called "find". (Yes, that's
available for Windozes too). From a Perl script, I'd simply call that
program:
my @files = `find $dir -name '*.txt'`;
I can't get it to normalize the path separators yet, it returns names
with these hideous backslashes even when you give it 'c:/images/' as a
dir.
OK, let's hack All.pm and add a line to its sub new:
my $name = shift;
$name =~ s~\\~/~g if $^O eq 'MSWin32';
Not a nice fix, but for now that solved my problem with it.
OK, let's hack All.pm and add a line to its sub new:
my $name = shift;
$name =~ s~\\~/~g if $^O eq 'MSWin32';
Not a nice fix, but for now that solved my problem with it.
perldoc readdir
A. Sinan Unur said:Using File::Find has its advantages [over IO::All], especially when a large number of
files need to be processed. Think of the difference between: [snipped benchmarks]
emallove said:^^^^^^^^^^^
^^^^^^^^^^^
perl -e ' \
opendir(d,"."); \
foreach (readdir(d)) { \
print "$_\n" if (/.txt/); \
} \
closedir(d);'
Samwyse said:How about this, in 'package main':
use IO::All;
BEGIN {
our $previous_new = \&IO::All::new;
}
sub IO::All::new {
my ( $class, $name) = @_;
$name =~ s~\\~/~g if $^O eq 'MSWin32';
&$previous_new(@_);
}
Anno Siegel:
How about this, in 'package main':
use IO::All;
BEGIN {
our $previous_new = \&IO::All::new;
}
sub IO::All::new {
my ( $class, $name) = @_;
$name =~ s~\\~/~g if $^O eq 'MSWin32';
&$previous_new(@_);
}
I wish to be able to find all .txt files in a dir recursively using
perl script, can anyone tell me how to write this perl script?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.