here's the code:
#!/usr/bin/perl my @data; my $query; if ( $ENV{REQUEST_METHOD} eq 'POST' ) { read(STDIN, $query, $ENV{CONTENT_LENGTH}); } else { $query = $ENV{QUERY_STRING}; } for ( split /&/, $query ){ my ($key, $val) = split /=/; map{ s/\+/ /g; s/%(..)/pack("c", hex($1))/eg; } ($key, $val); $form{$key} = $val; } InitData(); print "Content-type: text/html\n\n"; if ($form{mode} eq 'list'){ List(); } elsif ($form{mode} eq 'register'){ Register(); } elsif ($form{mode} eq 'admin'){ Admin(); } elsif ($form{mode} eq 'admin_change'){ AdminChange(); } else { ShowRegister(); } sub List { my $num = $#data; my $table = "<body bgcolor=black text=\"#FE6500\">Number of people + registered : $num&nbsp;&nbsp;&nbsp;Cost for all is \12 dollars<table + border=1 bordercolor=\"#FE6500\"><tr bgcolor=\"#FE6500\"><td><font c +olor=black>Name</font></td><td><font color=black>Handle</font></td><t +d><font color=black>Paid?</td></font></td></tr>"; for (@data) { $table .= "<tr><td>".$_->{fname}.' '. $_->{lname}."</td>". "<td>".$_->{handle}."</td>". "<td>".$_->{paid}."</td></tr>"; } $table .= "</table>"; print $table; } sub ShowRegister { print <<THAT; <html> <body bgcolor=black> <font color = "FE6500"> <form action="http://www.urban-lan.net/register.pl" method=POST> First Name: <input type=text name=fname><br> Last Name: <input type=text name=lname><br> Handle: <input type=text name=handle><br> <input type=hidden name=mode value=register> <input type=submit value=Register> </font> </form> THAT } sub Register { push @data, {'fname' => $form{fname}, 'lname' => $form{lname}, 'handle' => $form{handle}, 'paid' => 'no'}; print <<THIS; <html> <body bgcolor="black"> <font color="FE6500"> Thanks for registering! <a href="http://www.urban-lan. +net/main.html" target = "B">Back to Urban LAN</a> </font> </html> THIS SaveData(); } sub Admin { if ( $form{user} eq 'ryan' && $form{pass} eq '9810able12') { my $html = "<form method=POST action=register.pl>"; $html .= "<table border=1 bordercolor=black><tr><td>First Name +</td><td>Last Name</td><td>Handle</td><td>Paid?</td></tr>"; my $i = 0; for (@data) { $html .= "<tr><td><input type=text name=fname-$i value=\"" +.$_->{fname}."\"></td>"; $html .= "<td><input type=text name=lname-$i value=\"".$_- +>{lname}."\"></td>"; $html .= "<td><input type=text name=handle-$i value=\"".$_ +->{handle}."\"></td>"; $html .= "<td><input type=text name=paid-$i value=\"".$_-> +{paid}."\"></td></tr>"; $i++; } $html .= "</table>"; $html .= "<input type=hidden name=mode value=admin_change>"; $html .= "<input type=hidden name=user value=ryan>"; $html .= "<input type=hidden name=pass value=9810able12>"; $html .= "<input type=submit value=Save>"; $html .= "</form>"; print $html; } } sub AdminChange { if ( $form{user} eq 'ryan' && $form{pass} eq '9810able12' ) { my $i = 0; for ( @data ) { $_->{fname} = $form{'fname-'.$i}; $_->{lname} = $form{'lname-'.$i}; $_->{handle} = $form{'handle-'.$i}; $_->{paid} = $form{'paid-'.$i}; $i++; } print "<a href=http://www.urban-lan.net/register.pl?mode=admin +&user=ryan&pass=9810able12>Back to table</a>"; SaveData(); } } sub InitData { open( DATA, ".data"); for (<DATA>) { my ($first,$last,$handle,$paid) = split /==/; chomp $paid; push @data, {'fname'=>$first,'lname'=>$last,'handle'=>$handle, +'paid'=>$paid}; } close (DATA); } sub SaveData { open (DATA, ">.data"); for (@data) { print DATA $_->{fname}.'=='. $_->{lname}.'=='. $_->{handle},'=='. $_->{paid}."\n"; } close DATA; }
If that helps any

Edited: ~Wed Jul 31 23:06:03 2002 (GMT) by footpad: Added <readmore tag>, per Consideration


In reply to Re: perl script not running properly off web server by elffin
in thread perl script not running properly off web server by elffin

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.