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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



Jolle
New User

Aug 21, 2009, 12:18 PM

Post #1 of 2 (626 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 :

Code
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 Genextract.pl $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, Genextract.pl 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 GenExtract.pl 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 GenExtract.pl

Anybody an idea? Thx already.


FishMonger
Veteran / Moderator

Aug 21, 2009, 3:55 PM

Post #2 of 2 (620 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.

http://codingforums.com/showthread.php?t=175109

 
 


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

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