in reply to Finding Files and Processing them iteratively

You can cycle through all the files with that pattern with glob.

Something like that (untested code):

#!/usr/bin/perl use strict; use warnings; for ( glob data*R.fa ) { my $Rfile = $_; s/R(?=\.fa)$/P/; my $Pfile = $_; # Your code here }