in reply to Finding Files and Processing them iteratively

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!

Replies are listed 'Best First'.
Re^2: Finding Files and Processing them iteratively
by monkfan (Curate) on Feb 25, 2005 at 13:53 UTC
    Hi Random Walk,
    Thanks so much answering. I've tested your code. It works great.
    Just wonder how can I modify the code, such that it capture the file automatically.

    Currently I have to pass the all files argument manually like this:
    perl mycode.pl data1P.fa data1R.fa data2P.fa data2R.fa ....etc
    Because there are many many files like this. Can it be automated?
    Regards,
    Edward