[Israel.pm] Talk: A natural flow for web apps

Ran Eilam eilara at cortext.co.il
Fri Mar 19 14:26:36 PST 2004



Name: From the Command Line to the Browser

Length: 20 minutes

Summary: will show a very experimental web development trick, that lets
you call web pages as subs.

Consider a command line application that gets 2 numbers and prints their
sum:

  sub flow {
     my $a = prompt('Enter a number:');
     my $b = prompt('Enter another number:');
     prompt('Sum is: '. ($a + $b). '. Hit Enter to continue.');
  }

It is easy to write a prompt() that will do what we need. Something
like:

  sub prompt {
     my $message = shift;
     print "$message\n";
     chomp(my $out = <>);
     return $out;
  }

How do you write a prompt() that will allow flow() to run unchanged, but
as a web app consisting of 3 pages?

Having prompt() itself accept an HTTP request from a connection, is not
allowed. Why? flow() needs to run in a standard web server, like
mod_perl, and they dont allow that. flow() will be called from an HTTP
request handler, thus the request has already been accepted.

During the talk we will look at a working solution, and see why it is
problematic.

Ran



More information about the Perl mailing list