#! /bin/env perl
# text.pl -- get HTML <title>..</title>
#TODO:
# * 支持在第二行处的标题:
# <title>
# This is title </title>
# * 支持去除标题开头的空格
#
#
#您能帮我改进一下吗?请将结果发到<gjp1120@gmail.com>
#十分感谢!
use strict;
use warnings;
my @files =
glob "*.html";
foreach my $file (@files)
{
do_file($file);
}
sub do_file
{
my ($file_name) =
shift @_;
foreach (<FD>){
if (/<title>/i){
$_ = $t[$#t];
$_ = $t[0];
$_ = $t[0];
$_ = $t[0];
#print $_ . "n";
change_name($file_name, $_);
}
}
}
sub change_name
{
(my $fn, my $nfn) = @_;
#print $nfn;
rename $fn,
"newfs/".
$nfn.
'.html';
}