Tuesday, December 1, 2009

reading files from a dir in PERL

I always forget the silly syntax for this, so here it is:

#!/usr/bin/perl -w

opendir(DIR, ".");
@files = grep(/\.fasta$/,readdir(DIR));
closedir(DIR);

foreach $file (@files) {
   #do something
}

No comments:

Post a Comment