Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Subroutine accessible as yourdomain.com/cgi-bin/foo.pl?foo

by damian1301 (Curate)
on Oct 27, 2000 at 05:34 UTC ( [id://38761]=perlquestion: print w/replies, xml ) Need Help??

damian1301 has asked for the wisdom of the Perl Monks concerning the following question: (subroutines)

How is it done?!

Originally posted as a Categorized Question.

  • Comment on Subroutine accessible as yourdomain.com/cgi-bin/foo.pl?foo

Replies are listed 'Best First'.
Re: Subroutine accessible as yourdomain.com/cgi-bin/foo.pl?foo
by chromatic (Archbishop) on Oct 27, 2000 at 05:53 UTC
    Jellybean is based on this idea.

    The easiest thing to do is to create a hash of code refs. Pull out the query string or URL information or whatever, then use that data as the hash key.

    If there's a valid code ref there, call that subroutine. If not, show an error or do a default sub.

    For example, you could write:

    my %sub_refs = ( foo => \&do_this, bar => \&do_that, ); my $request = $ENV{QUERY_STRING}; if (defined(my $action = $sub_refs{$request})) { $action->(); } else { default(); }
    I'd do something more sophisticated in place of the query string scheme, as it's not terribly brilliant.
Re: Subroutine accessible as yourdomain.com/cgi-bin/foo.pl?foo
by merlyn (Sage) on Oct 27, 2000 at 07:53 UTC
    See Apache::Dispatch. Yup. The normal answer: "There's a CPAN module that does this." {grin}

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://38761]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-25 17:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found