3 ###APPAUTHOR: xiaoranzzz
4 ###APPDATE: Wed Apr 28 02:26:38 2010
6 ###APPDESC: html2unix convert \"href\" \"src\" to lowercase
8 ###APPEXAMPLE: html2unix
12 #ENV variable MUST be defined somewhere,
13 #FOR perl to search modules from,
15 use lib
$ENV{XR_PERL_MODULE_DIR
};
17 use MyPlace
::Script
::Usage qw
/help_required help_even_empty/;
18 #exit 0 if(help_required($0,@ARGV));
19 exit 0 if(help_even_empty
($0,@ARGV));
20 use HTML
::TreeBuilder
;
25 foreach my $attr (qw
/src href/) {
26 my @elms = $tree->look_down($attr,qr/./);
27 map {$_->attr($attr,lc($_->attr($attr)))} @elms;
32 foreach my $file (@ARGV) {
34 my $tree = HTML
::TreeBuilder
->new_from_content(<STDIN
>);
36 print FO
$tree->as_HTML();
39 elsif(-f
$file and $file =~ m/\.(?:html|htm|xml|xhtml)$/) {
40 print STDERR
"Converting $file...";
41 my $tree = HTML
::TreeBuilder
->new_from_file($file);
43 open FO
,">".$file or die("$!\n");
44 print FO
$tree->as_HTML();
47 print STDERR
"\t [OK]\n";
50 print STDERR
"\"$file\" Ingored.\n";