Bleg For Perl Help

I am not an accomplished Perl hacker and something has been frustrating me at work for the last several weeks.  If you know of an easy way to solve this, I will be forever in your debt:

We are using Perl to run a HTTP server (HTTP::Daemon, incidentally, works like a charm) to receive information from a rich client application.  The client has to upload text files via HTTP post.  Everything is A-OK on the client’s side of things, but I have no clue how to go about extracting the uploaded text file from the HTTP request on the server side of things.  My experiments have been a bunch of failures, I can’t seem to find any CPAN Module which will do this cleanly, and there are other deliverables up in the air which are getting held up by the server being only 98% complete (that last pesky 2% is critical to testing the client application, sadly).  Does anyone have any suggestions?  Perl’s documentation is, well…  up to its usual standard of lucidity.

Advertisements
Explore posts in the same categories: Uncategorized

6 Comments on “Bleg For Perl Help”

  1. Ali Says:

    I would help if you were using PHP 😦

  2. Nick Says:

    If you’re trying to upload data from a client to a server over http, look into XML-RPC. You can implement an xmlrpc server that listens on port 80 that your client can upload data to.

    From the xml-rpc homepage:
    It’s remote procedure calling using HTTP as the transport and XML as the encoding. XML-RPC is designed to be as simple as possible, while allowing complex data structures to be transmitted, processed and returned.

  3. Patrick Says:

    We actually are using XML-RPC in a different portion of the project. Unfortunately, we are already more-or-less committed to using the server code which we have (i.e. Perl and HTTP transfer), since retooling it would more or less involve a rewrite (the server has no business logic on it, its essentially just for data transfer between clients).

  4. Matt Says:

    HTTP::Request::Params is what you want. It does exactly what you want:

    my $d = HTTP::Daemon->new(LocalPort => 80);
    while (my $c = $d->accept) {
    while (my $r = $c->get_request) {
    if ($r->method eq ‘POST’) {
    my $params = HTTP::Request::Params->new({req => $r})->params;

    $params is now a ref to a hash that contains all the key/value pairs you need, including the content of any uploaded files.

  5. Patrick Says:

    I could kiss you.

  6. Matt Says:

    Luckily, I’m on the other side of the ocean from you… 🙂


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: