Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
use strict; use warnings; use CGI qw/:all *table/; use Cache::FileCache; my $cache = new Cache::FileCache({namespace => 'coffee'}); my $cgi = new CGI; print $cgi->header; print $cgi->start_html({bgcolor=>'white', title=>'Someone get the coff +ee'}); print h1({align=>'center'}, "Someone get the coffee"); if ($cgi->param("action")) { my $action = $cgi->param("action"); if ($action eq "add") { my $name = $cgi->param("name"); my $email = $cgi->param("email"); unless ($name and $email) { print "Get lost.\n"; print hr(); exit; } else { $cache->set($name, $email, "1 day"); } my @keys = $cache->get_keys(); if (@keys > 2) { foreach my $key (@keys) { my $email = $cache->get($key); open(FOO, "|mail $email"); print FOO "Subject: someone get the coffee\n\n"; foreach my $keyagain (@keys) { print FOO "$keyagain - " . $cache->get($keyagain) +. "\n"; } print FOO $cgi->url() . "\n\n.\n"; close(FOO); } } } elsif ($action eq "deleteall") { $cache->clear(); } else { print "Get lost.\n"; print hr(); exit; } } my @keys = $cache->get_keys(); unless (@keys > 0) { print p({align=>'center'}, "No orders right now."); } else { print start_table({cellpadding=>3,cellspacing=>3, align=>'center'} +); print Tr({bgcolor=>'blue'}, td( span({style=>'color: white'}, "Name")), td( span({style=>'color: white'}, "E-mail")) ); foreach my $key (@keys) { my $email = $cache->get($key); print Tr( td($key), td($email) ); } print end_table(), p(); } print start_form({url=>$cgi->self_url, method=>'get'}), start_table(), Tr( td( "Name" ), td( textfield({name=>'name'}) ), ), Tr( td( "Email" ), td( textfield({name=>'email'}) ) ), end_table(); print start_table(), Tr( td(submit({name=>'action', value=>'add'}, "add")), td(submit({name=>'action', value=>'deleteall'}, "deleteall")), td(button({name=>'refreshpage', value=>'refreshpage', onClick=>"document.location.href=\"" . $cgi->url() . "\" +; return;"})) ), end_table(); print end_form();

In reply to Someone get the coffee by hagus

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2024-03-28 22:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found