If you mean to run the script with a long list of R/P file names then this will do it. Note as the P names are derived from the R names you only need give a list of R names. If the extension is always the same a list of base names would do, should be trivial to get there from here.
#!/usr/bin/perl
use strict;
use warnings;
for (@ARGV) {
next if /P\./; # ignore the P files
my ($base, $ext)= split /R/; #assume only one 'R' in the file name
r_p_process ( $base."R".$ext, $base."P".$ext )
}
sub r_p_process {
my $r_file=shift;
my $p_file=shift;
print "processing the pair $r_file $p_file\n";
# do your funky stuff
}
Cheers,
R.
Pereant, qui ante nos nostra dixerunt!