How to process every file in a directory that matches a pattern - Perl Views : 266
Tagged in : Perl
0 0
Send mail
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 .