For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > October 2006 > Before I get started with Perl......









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Before I get started with Perl......
D.Kochman@gmail.com

2006-10-02, 7:58 am

So I need to write a basic script, and I figure Perl is the best place
to go, but I want to be sure before I spend some time learning it. ;)

Anyways, what I have another program for fitting curves, but the
architecture of the program doesn't make it very 'batchable'.

So I want to write a script that will 1) open the program, and
sequentially open the files in a directory, fit the curve, and then
export the results to another folder.

Heres the tricky part, the sequential opening of the next file can only
happen after the program *stops* fitting (which can take variable
amounts of time). As far as I know, it really doesn't give any signal
that its done other than updating the display with the fit curve. The
program itself is fairly memory/cpu intensive, when fitting, which is
the reason I have to do them sequentially. I have to do this for >1000
files, so I'd rather not sit around and do it manually. =X

Is this possible?

usenet@DavidFilmer.com

2006-10-02, 6:59 pm

D.Kochman@gmail.com wrote:

> Heres the tricky part, the sequential opening of the next file can only
> happen after the program *stops* fitting (which can take variable
> amounts of time). As far as I know, it really doesn't give any signal
> that its done other than updating the display with the fit curve.


Then what "results" are you writing to a file? Where do the results
come from?

You really don't' give enough information about how your curve-fitting
program is launched and how it behaves. If it has no commandline
interface (but is GUI only) then it can be somewhat complicated to
automate. If it has a commandline interface, you ought to be able to
launch the command (using backticks syntax) and Perl will wait for it
to complete.

You don't say what type of curve fitting. Have you considered a
pure-Perl implementation using one of the curve-fitting modules on
CPAN, such as Algorithm::CurveFit?

--
David Filmer (http://DavidFilmer.com)

D.Kochman@gmail.com

2006-10-02, 6:59 pm


> Then what "results" are you writing to a file? Where do the results
> come from?


Sorry, I was being a bit rushed with the post, I'll try to be a bit
more clear - the curve fitting program has a menu choice for outputting
the solutions after the fit is done. It outputs the values of all the
parameters, and then it outputs 3 colums - the first is the bin #, the
second is the value of the original curve, and the thrid is the value
of the fitted curve.

> You really don't' give enough information about how your curve-fitting
> program is launched and how it behaves. If it has no commandline
> interface (but is GUI only) then it can be somewhat complicated to
> automate. If it has a commandline interface, you ought to be able to
> launch the command (using backticks syntax) and Perl will wait for it
> to complete.


The program It is written in IDL. There is a command line for the
interpreter, however this is a graphical program. I will see what I
can possibly output from the command line when its complete. (I have
the source code for the other one as well.)

>
> You don't say what type of curve fitting. Have you considered a
> pure-Perl implementation using one of the curve-fitting modules on
> CPAN, such as Algorithm::CurveFit?


This function it is fitting is fairly complicated and involves multiple
convolutions with instrument response functions, combined with multiple
different parameters and an exponential decay. As the code is written
already, I'll just stick with it for now, as in IDL it takes up about
2000 lines of code, not including the GUI.

Once again, sorry for the slightly sloppy first post. It seems like
based on what you are saying, if I can trigger it from the command line
after its finished, it should be able to write a script for this in
Perl, right?

usenet@DavidFilmer.com

2006-10-02, 6:59 pm

D.Kochman@gmail.com wrote:
> Once again, sorry for the slightly sloppy first post. It seems like
> based on what you are saying, if I can trigger it from the command line
> after its finished, it should be able to write a script for this in
> Perl, right?


I'm still not clear on your question. I don't know what you mean by:

> If I can trigger it from the command line after its finished,


Suppose you have a program called "curvefit" If you type "curvefit" at
a shell prompt, it brings up a GUI or prompt or webpage which you must
interact with in order to do anything. That's a challenge - you need
to have a script interact with the program. That can be easy, or it
can be hard. If the program simply prompts the user for input, you can
use Expect to interact with it. If it uses a web-based form to get
input, you can use WWW::Mechanize to interact with it. If it's
TK-based, I dunno (but it's probably possible). If it's something
else, it may be possible or it may be (practically) impossible.

However, if you can run the program in batch mode, such as:

curvefit --inputfile=/path/foo.in --outputfile=/path.foo.out

then you can easily call this from Perl (using backticks). Perl will
invoke the program and wait for it to finish. When the external
program finishes, Perl will resume (and can then parse the output file
or whatever you like).

--
David Filmer (http://DavidFilmer.com)

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com