Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re^3: Absolute simplest way to keep a database variable persistent?

by toma (Vicar)
on Oct 05, 2008 at 19:17 UTC ( #715448=note: print w/replies, xml ) Need Help??

in reply to Re^2: Absolute simplest way to keep a database variable persistent?
in thread Absolute simplest way to keep a database variable persistent?

One way to wrap a perl program is to use a web server. Create a server that takes an input of two strings and return the relatedness. The server can keep WordNet loaded between requests.

The server could be something like Apache and mod_perl, or it could be something like POE::Component::Server::HTTP.

I use the Cygwin environment and the POE modules to interface to other programs this way. However, I wasn't able to get POE working well until a learned a fair amount of Perl. Maybe you will get lucky and find a POE example that is very close to what you need.

This might not be the 'absolute simplest' to develop, but after you get it working your code will be quite simple!

It should work perfectly the first time! - toma
  • Comment on Re^3: Absolute simplest way to keep a database variable persistent?

Replies are listed 'Best First'.
Re^4: Absolute simplest way to keep a database variable persistent?
by natestraight (Novice) on Oct 06, 2008 at 13:57 UTC
    Yeah, I thought about using a server to handle the issue. The problem with this method is that, ideally, my finished application (excel sheet + custom VBA functions + working Perl scripts) is going to be transferred to other users, who are not even able to be considered n00bs. I'm trying to keep the techie overhead and the requisite configuration to a minimum so that I can just bundle up the necessary Perl directories in a .zip and send them along with my spreadsheet.
      Instead of using a webserver, have your Perl script fork off its own server (if one isn't running at the time). It can communicate on a socket. We have a CGI program that keeps an large XSLT in standby. Using IO::Socket:
      my $sock = new IO::Socket::INET ( LocalHost => $server, LocalPort => 9200, Proto => 'tcp', Listen => 2, ReuseAddr => 1, ); die "socket creation error: $!" unless $sock; while( my $client = $sock->accept() ) { binmode $client, ":utf8"; $client->autoflush(1); # Read data while( $client->recv( $in_buffer, $buffer_size ) ) { # Store data } # Process data # Return data $client->send( $output ); }
      Some things to consider to make it dummy proof is allow it to adjust what port is runs on at runtime, and to have the server exit after a while to avoid zombie processes.
        Sounds possible. Thanks for the sample code, too.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://715448]
[thepkd]: sorry. i mean $aohoaoh[0]
[GotToBTru]: $aohoaoh is an array reference tho
[thepkd]: some guy was suggesting $aohoaoh[0]->{'foo '}[0]->{}. This wouldnt work.
[GotToBTru]: you're mixing notation there I think
[GotToBTru]: $aohoaoh->[0] is a hash reference, so $aohoaoh->[0]->{ key1} would work
[1nickt]: If 1nickt is the some guy, that's not what he said.
[GotToBTru]: thepkd might not know about last hour of cb
[1nickt]: my $x = $aohoaoh->[0]->{' foo'}->[0]->{'bar' }; should work
[thepkd]: its not $aohoaoh->[0]. its $aohoaoh[0]->{'foo '}. Tried it. Its working. Thnaks

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (12)
As of 2016-12-06 13:37 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (105 votes). Check out past polls.