⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fig16_12.pl

📁 PERL语言资料 可以用于PERL程序设计
💻 PL
字号:
#!/usr/bin/perl
# Fig. 16.12: fig16_12.pl
# Reads books from a database and prints them in a table

use warnings;
use strict;
use CGI qw( :standard );

my @data;

print( header(), start_html( "Book List" ) );

open( BOOKS, "catalog.txt" ) or
   die( "The database could not be opened." );

print <<End_Begin;

<center>Books available for sale<br>

<a href = "fig16_13.pl">Sign Out</a><br>

<table border = "1" cellpadding = "7">
<tr>
   <th>Name</th>
   <th>Year</th>
   <th>ISBN</th>
   <th>Price</th>
</tr>

End_Begin

# print books the user can buy
while ( <BOOKS> ) {

   @data = split( "\t" );       # Variable $_ assumed

   print( "<form method = \"post\" action = \"fig16_11.pl\">" );
   param( "remove" , 0 );    # The user is not removing a book,
   param( "newbook", @data );   # They are adding a book
   print( hidden( "remove" ) );
   print( hidden( "newbook"), "\n<tr>" );

   foreach ( @data ) {
      print( "<td>$_</td>" );   # print data item within a cell
   }

   print( "<td>", submit( "Buy" ), "</td></tr></form>\n" );
}

print( "</table>" );

print( end_html() );
close( BOOKS ) or die( "Cannot close file: $!" );

###########################################################################
#  (C) Copyright 2001 by Deitel & Associates, Inc. and Prentice Hall.     #
#  All Rights Reserved.                                                   #
#                                                                         #
#  DISCLAIMER: The authors and publisher of this book have used their     #
#  best efforts in preparing the book. These efforts include the          #
#  development, research, and testing of the theories and programs        #
#  to determine their effectiveness. The authors and publisher make       #
#  no warranty of any kind, expressed or implied, with regard to these    #
#  programs or to the documentation contained in these books. The authors #
#  and publisher shall not be liable in any event for incidental or       #
#  consequential damages in connection with, or arising out of, the       #
#  furnishing, performance, or use of these programs.                     #
###########################################################################

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -