[Israel.pm] Demonizing a commanline utility

Itzik Lerner - Orpak itzik at orpak.co.il
Tue Mar 1 03:51:18 PST 2005


Hi Shlomo

I think you can do it with IPC::Open3

With this module you can open a pipe to an external process 
Which in this case is your binary utility.
And you get 3 file handles for the STDIN,STDOUT and STDERR of the process
Then he remains in the 'air' all the time and you don't have to load again
and again


Example:
	use IPC::Open3;
	my $pid = open3(\*MYOUT, \*MYIN, \*MYERR,
         'some external program', 'optional argument', ...);
	....
	print MYOUT 'some input to your external program';
	my $result=<MYIN>;

and so on...

bye
--Itzik


-----Original Message-----
From: Shlomo Yona [mailto:shlomo at cs.haifa.ac.il] 
Sent: Monday, February 28, 2005 7:06 PM
To: perl at perl.org.il
Subject: [Israel.pm] Demonizing a commanline utility

Hello,

I have a commanline utility that accepts input from the
standard input and then produces its output at the standard
output. So far so good.
This utility, when invoked, loads a very large data
structure into memory, an operation that takes a few
seconds, but once this data structure is loaded, the utility
produces output in a very high rate.

I would like to "deamonize" this utility so it can be loaded
once (including that expensive data structure loading) but
then accept input and produce output rapidly, without paying
the "loading" penalty every time.

This utility is a binary file that I have licensed from a
vendor. There's no way to get the sources or have the vendor
change it.

Any suggestions?

-- 
Shlomo Yona
shlomo at cs.haifa.ac.il
http://cs.haifa.ac.il/~shlomo/
_______________________________________________
Perl mailing list
Perl at perl.org.il
http://perl.org.il/mailman/listinfo/perl



More information about the Perl mailing list