#!/usr/bin/perl
use CGI;
$query = new CGI;
$act = $query->param( 'act' );
if ( $act eq "List" ) {
$select = $query->param( 'select' );
if ( $select eq "all" ) {
print ( "Content-type: text/plain\n\n\n\n\n" );
system( "sort books.txt" )
}
elsif ( $select eq "one" ) {
$ISBN = $query->param( 'ISBN' );
# Remove the white spaces before and after the ISBN.
$ISBN =~ s/^\s*(.*?)\s*$/$1/g;
$_ = $ISBN;
if ( /\w{10}/ || /\w{11}/ || /\w{12}/ || /\w{13}/ || /\w{14}/ || /\w{15}/ ) {
print ( "Content-type: text/plain\n\n\n\n\n" );
system( "grep $ISBN books.txt" );
}
else {
print( "Content-type: text/html\n\n" );
print( "Wrong ISBN: $ISBN" );
}
}
else {
print( "Content-type: text/html\n\n" );
print( "No such option: $select" );
}
}
elsif ( $act eq "Help" ) {
print ( "Content-type: text/html\n\n" );
system( "/bin/cat Help.html" );
}
elsif ( $act eq "Home" ) {
print ( "Content-type: text/html\n\n" );
system( "/bin/cat FPDemo.html" );
}
else {
print( "Content-type: text/html\n\n" );
print( "No such option: $act" );
}
|