Hi,
I need to find out ONLY all the text files (*.[hc], and scripts) in a given directory (which may have a lot of sub-, sub-sub-, ...), using Perl. Following is my sample code, but it gave me all kind of files (*.o, *.a). Instead of -d, is there any other options I can use just for text file?
Any thought is greatly appreciated.
Michael
---
use File::Find;
sub change {
if ( -d ) {
print "\nIn directory: $_ \n";
}
if( -f ) {
print " -- $_ \n";
}
}
my @dirs = qw(.);
if ($#ARGV+1 == 0) {
find ( \&change, @dirs );
}else {
print "Usage: prinfile.pl!";
exit;
}
---
I need to find out ONLY all the text files (*.[hc], and scripts) in a given directory (which may have a lot of sub-, sub-sub-, ...), using Perl. Following is my sample code, but it gave me all kind of files (*.o, *.a). Instead of -d, is there any other options I can use just for text file?
Any thought is greatly appreciated.
Michael
---
use File::Find;
sub change {
if ( -d ) {
print "\nIn directory: $_ \n";
}
if( -f ) {
print " -- $_ \n";
}
}
my @dirs = qw(.);
if ($#ARGV+1 == 0) {
find ( \&change, @dirs );
}else {
print "Usage: prinfile.pl!";
exit;
}
---