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

📄 fig17_11.pl

📁 PERL语言资料 可以用于PERL程序设计
💻 PL
字号:
#!/usr/bin/perl
# Fig. 17.11: fig17_11.pluse strict;
use warnings;
use MD5;
use Mail::POP3Client;
use CGI qw( :standard );

my $user = param( "userName" );
my $password = param( "password" );
my $server = param( "server" );
my $offset = param( "offset" );

print( header() );
print( start_html( -title => "Check your mail!" ) );

my $pop = new Mail::POP3Client( USER => $user, 
   PASSWORD => $password, HOST => $server ) or
   print( h1( "Cannot connect: $!" ) );

my $messages = $pop->Count();
print( "<p>You have $messages messages in your inbox.</p>" );
my $offset1 = $offset - 5;
my $offset2 = $offset + 5;
my $start = 1 + $offset;
my $end = ( $offset2 < $messages ? $offset2 : $messages );

for ( $start .. $end ) {
   print( "<p>$_: " );

   foreach ( $pop->Head( $_ ) ) {
      /^(From|subject):\s+/i and print $_, "<br/>";
   }

   print( "</p>\n" );
}

print <<FORM1 if ( $offset );
<form action = "fig17_11.pl" method = "post">
<input name = "userName" value = $user type = "hidden"> 
<input name = "password" value = $password type = "hidden"> 
<input name = "server" value = $server type = "hidden"> 
<input name = "offset" value = $offset1 type = "hidden"> 
<input type = "submit" value = "See previous 5">
</form>
FORM1

print <<FORM2 if ( $end != $messages );
<form action = "fig17_11.pl" method = "post">
<input name = "userName" value = $user type = "hidden"> 
<input name = "password" value = $password type = "hidden"> 
<input name = "server" value = $server type = "hidden"> 
<input name = "offset" value = $offset2 type = "hidden"> 
<input type = "submit" value = "See next 5">
</form>
FORM2

print( end_html() );

$pop->Close();

###########################################################################
#  (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 + -