On Wednesday 23 Jun 2010 23:31:29 Chap Harrison wrote: > Hi, > > I have a Perl app that makes SQL queries to DBF (DBase IV) databases. I > haven't found a reliable DBI::DBD module for accessing DBase IV, but I do > have a copy of the JDBC library, so I wrote a simple Java command-line > program that accepts a database path and a query on the command line, > connects to the database, executes the query, and writes the result set to > STDOUT. Then, from Perl, I write > > my @rows = qx(java lmi_DBFAccess -d '$db_path' -q "$sql_query"); > > It's kludgy, but it works. However, due to the overhead of qx, and of > establishing a fresh connection to the database for every query, it's > slow, and I want to improve it. > > I figure that I should convert lmi_DBFAccess to run as a local daemon, and > use IPC to send the above parameters - and receive the results. > lmi_DBFAccess will now cache its previously-established connections and > use them when needed. > > I've never done IPC before (well, besides command piping). I've been > wading through perlipc, and I have a headache. Would someone be so kind > as to give a high-level outline of what I need to do on the Perl side? >
Look at IO::Socket ( http://search.cpan.org/perldoc?IO::Socket::INET ) and maybe IO::All ( http://search.cpan.org/dist/IO-All/ ). You initialise a socket, connect() to a remote port, and then you can use print , read (or <...> in Perl's case) and when you're done - close(). Regards, Shlomi Fish > Some salient details: > > -- I'm running in Cygwin on Windows Server 2003 > -- Perl 5.10 > -- As can be inferred from the qx above, a synchronous protocol is fine. > > Sure do appreciate it! > Chap Harrison -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ What Makes Software Apps High Quality - http://shlom.in/sw-quality God considered inflicting XSLT as the tenth plague of Egypt, but then decided against it because he thought it would be too evil. Please reply to list if it's a mailing list post - http://shlom.in/reply . -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/