I just wish I did! Now that you've updated your question to be more specific, I can once again recommend Dancer, Catalyst, Mojolicious(::Lite), or even HTTP::Server::Simple.

Here is an example of your desire(borrowed code from the latter):

#!/usr/bin/perl { package MyWebServer; use HTTP::Server::Simple::CGI; use base qw(HTTP::Server::Simple::CGI); my %dispatch = ( '/bla' => \&resp_bla, ); sub handle_request { my $self = shift; my $cgi = shift; my $path = $cgi->path_info(); my $handler = $dispatch{$path}; if (ref($handler) eq "CODE") { print "HTTP/1.0 200 OK\r\n"; $handler->($cgi); } else { print "HTTP/1.0 404 Not found\r\n"; print $cgi->header, $cgi->start_html('Not found'), $cgi->h1('Not found'), $cgi->end_html; } } sub resp_bla { my $cgi = shift; # CGI.pm object return if !ref $cgi; print $cgi->header("text/plain"), (rand(10) < 5) # pick a random number and see if it is less + than 5... ? 1 : 0; #...and print 1 if it is, or 0 if it isn't. } } # start the server on port 8080 # access me at http://localhost:8080/bla my $pid = MyWebServer->new(8080)->background(); print "Use 'kill $pid' to stop server.\n";

Of course, you will want to do a more interesting check than a random number -- say, whether a file exists, a row is present in a table, or if it is a certain time of day.

~Thomas~ 
"Excuse me for butting in, but I'm interrupt-driven..."

In reply to Re^3: Web service without a server by thomas895
in thread Web service without a server by rudrakiran

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.