in reply to Finding Files and Processing them iteratively
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 } [download]