#!/usr/bin/perl #Make HTML files form many picture. #Put this file in the dir where big pictures are. use warnings; my $backcolor='blue'; my $dirname=''; my $subdirname=''; my @picdata=(); my $htmlfile=''; my $framefile=''; my $htmlcontent=''; my $framecontent=''; my $title=''; my $line=''; print "Please enter the color of the background of the HTML files:\n"; $backcolor=; chop($backcolor); print "Please enter the name of the pictures' dir:\n"; $dirname=; chop($dirname); print "Please enter the name of the subpictures' subdir:\n"; $subdirname=; chop($subdirname); print "请输入中文标题:\n"; $title=; chop($title); $htmlfile=$dirname.'pic.htmll'; $framefile=$dirname.$subdirname.'.htmll'; open(HTML, ">$htmlfile"); open(FRAME, ">$framefile"); @picdata=get_file_data("dir.txt"); $framecontent='天目行--'.$title .''."\n" .''."\n" .''."\n" .''."\n" .'
'."\n" .''."\n" .''."\n" .''."\n"; foreach $line (@picdata) { $framecontent=$framecontent.''."\n"; } $framecontent.='
' .'DSC02218
'; print FRAME ($framecontent); close FRAME; $htmlcontent='天目行--'.$title.''."\n" .'' ."\n".'' ."\n".'' ."\n".'' ."\n".'' ."\n".'
' ."\n".'' ."\n".'
' ."\n".'' ."\n".'
'; print HTML $htmlcontent; close HTML; exit; sub get_file_data { my($filename) = @_; use strict; use warnings; # Initialize variables my @filedata = ( ); unless( open(GET_FILE_DATA,"<$filename") ) { print STDERR "Cannot open file \"$filename\"\n\n"; exit; } @filedata = ; close GET_FILE_DATA; foreach my $line (@filedata) { $line=~s/\s\s*/\n/g; } open(TEMP,">temp.txt"); print TEMP @filedata; close TEMP; @filedata=(); open(DATA,"; close DATA; return @filedata; }