How to process every file in a directory that matches a pattern - Perl Views : 250
Tagged in : Perl
Send mail vote down 0 vote down 0
You can use the glob operator to get a list of all files in the current directory like this:

@files = glob("*.*");

foreach $file (@files) {
print "$file\n" if -f $file;
}


you can modify your glob pattern to get a list of all the filenames that end with .pl, like this:

# look for all *.pl files
@files = glob("*.pl");

foreach $file (@files) {
print "$file\n" if -f $file;
}
By - Nithya, On - 2010-02-04




    Login to add Comments .