feiticeria
September 24th, 2006, 09:46 PM
To all those Perl geniuses out there, I am need of your help!
I am in charge of a university club website and the previous person running the show made a Perl based system to get people's name, year & email. This program is used for people to sign-up for events help by the club.
Now the problem, certain events have seating limits and I would like the program to stop people from signing-up when the limit is reached. So...i need:
- to create a variable to set the seating limit,
- another variable to act as a counter
- and when the counter has reached the limit variable, possibly have program redirect the person to a webpage (possibly using a "do while" loop).
Here is the current code:
#!/usr/bin/perl -wT
use CGI qw(:standard);
my $mail = param('EMAIL'); #in form name@host
if ( $mail !~ /^[0-9a-zA-Z\.\-\_]+\@[0-9a-zA-Z\.\-\_]+$/ ) #characters allowed on name: 0-9a-Z-._ on host: #0-9a-Z-._ on between: @
{
print "Location: http://stw.ryerson.ca/~acc/event-fail.html\n\n";
}
elsif ( $mail !~ /\.([a-zA-Z]{2,3})$/ ) { #host must end with '.' plus 2 or 3 alpha for #TopLevelDomain (MUST be modified in future!)
print "Location: http://stw.ryerson.ca/~acc/event-fail.html\n\n";
}
else
{
# now write (append) to the file
open(OUT, ">>record2.txt") or &dienice("Could not open output file: $!");
foreach my $p (param()) {
print OUT "|", param($p);
}
print OUT "\n";
close(OUT);
print "Location: http://stw.ryerson.ca/~acc/event-success.html\n\n";
}
I personally don't know perl, but I have some experience with Java, so I have an idea of how to fix my problem, just not too sure how to implement it with Perl.
Your help would be greatly appreciate. Even if you can tell me how to create a integer variable, it will go a long way.
I am in charge of a university club website and the previous person running the show made a Perl based system to get people's name, year & email. This program is used for people to sign-up for events help by the club.
Now the problem, certain events have seating limits and I would like the program to stop people from signing-up when the limit is reached. So...i need:
- to create a variable to set the seating limit,
- another variable to act as a counter
- and when the counter has reached the limit variable, possibly have program redirect the person to a webpage (possibly using a "do while" loop).
Here is the current code:
#!/usr/bin/perl -wT
use CGI qw(:standard);
my $mail = param('EMAIL'); #in form name@host
if ( $mail !~ /^[0-9a-zA-Z\.\-\_]+\@[0-9a-zA-Z\.\-\_]+$/ ) #characters allowed on name: 0-9a-Z-._ on host: #0-9a-Z-._ on between: @
{
print "Location: http://stw.ryerson.ca/~acc/event-fail.html\n\n";
}
elsif ( $mail !~ /\.([a-zA-Z]{2,3})$/ ) { #host must end with '.' plus 2 or 3 alpha for #TopLevelDomain (MUST be modified in future!)
print "Location: http://stw.ryerson.ca/~acc/event-fail.html\n\n";
}
else
{
# now write (append) to the file
open(OUT, ">>record2.txt") or &dienice("Could not open output file: $!");
foreach my $p (param()) {
print OUT "|", param($p);
}
print OUT "\n";
close(OUT);
print "Location: http://stw.ryerson.ca/~acc/event-success.html\n\n";
}
I personally don't know perl, but I have some experience with Java, so I have an idea of how to fix my problem, just not too sure how to implement it with Perl.
Your help would be greatly appreciate. Even if you can tell me how to create a integer variable, it will go a long way.