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

📄 fig11_10.pl

📁 PERL语言资料 可以用于PERL程序设计
💻 PL
字号:
#!perl
# Fig 11.10: fig11_10.pl
# Website update-page creator

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

our $indent = "|" . ( " " x 5 );
our $root = "I:/Apache/cgi-bin/";     #"C:/Program Files/Apache Group/Apache/cgi-bin/";   # our $root = "/Inetpub/wwwRoot/";
chdir( $root );
our @colors = qw( red orange green );
our @fileTypes = qw( html perl dir );
print( header(), start_html( -title => 'Update Page' ),
   '<font size = "+1">' );
print( "$root:<br/>\n" );
search( "", 1 );
print( "</font>" );
print( end_html() );

sub search
{
   my ( $directory, $offset ) = @_;
   opendir( DIR, $root . $directory ) 
      or die( "Error opening : $!" );

   foreach ( readdir( DIR ) ) {
      my $file = $directory . $_;
      printFile( 0, $file, $_, $offset ) if ( m/\.html/ );
      printFile( 1, $file, $_, $offset ) if ( m/\.pl/ );

      if ( -d $file && /[A-Za-z]/ ) {
         printFile( 2, $file, $_ . '/', $offset );
         search( $file . '/', $offset + 1 );
         print( "$indent" ) for ( 2 .. $offset );
         print( br(), "\n" );
         next;
      }
   }
}

sub printFile
{
   my ( $type, $file, $name, $offset ) = @_;
   my $full = $root . $file;
   print( "$indent" ) for ( 2 .. $offset );
   print( "|----" );
   my $color = $colors[ $type ];
   my $extension = $fileTypes[ $type ];
   print( "<font color = \"$color\">$extension: " );
   print( "$_</font>\n" );
   print( em( strong( "brand" ) ) ) if ( -M $full < 7 );
   print( strong( "new!" ), "\n" ) if ( -M $full < 30 );
   print( br(), "\n" );
}

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