CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
use perl script in loop without recompiling every time


New User

Aug 21, 2009, 12:18 PM

Post #1 of 2 (676 views)
use perl script in loop without recompiling every time Can't Post

Hi all,

I have a perl script to extract information from one file based on the information in a second. I use regularly with single files, but now I have to process a whole set of directories. So I wrote a second script that gets the necessary files for setting the parameters, and then I just do a system call :

foreach (@subdirs){ 
my $g;
my $i;
my $o = $GENE_DIR.$_."genes.txt";
chdir $_ or print "Could not change to $_\n" && next;
my @dirfiles = glob("*.txt");
foreach (@dirfiles){
if($_ =~ /(.+genomeFASTA.txt)/){$g=$1};
if($_ =~ /(.+genomeInfo.txt)/ ){$i=$1};
my $param = "g ".$g." i ".$i." o ".$o;
print $param."\n";
system("perl -S $param");
chdir "..";

The directory handling is a bit clumsy, I know, but that's to allow the system call to run without having to add the directory to every parameter.

Obviously, gets compiled every time again in the loop. There should be a way to do it without recompiling the whole time.

First answer is going to be "make it a module", but I need as a runnable script to analyze single files too.

I have been thinking about some construct with require, but I don't see how to use that in a loop and how to pass the parameters to @ARGV of

Anybody an idea? Thx already.

Veteran / Moderator

Aug 21, 2009, 3:55 PM

Post #2 of 2 (670 views)
Re: [Jolle] use perl script in loop without recompiling every time [In reply to] Can't Post

See my answer on this question at CF.


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives