Contact:[email protected]
tohtml.pl: put a HTML wrapper around a text
#!/usr/local/bin/perl
#change a text file to html
$first = 1;
print <html>;
print "\<head\>\n";
while ($line = <>) {
if ($first) {
$first = 0;
print "\<title\>$line\</title\>\n";
print "\</head\>\n";
print "\<body\>\n";
$line =~ s!(.*)!\<h1\>\1\</h1\>!;
print $line;
}
else {
# next 3 lines presume there isn't any html markup already
# in the file
$line =~ s/&/&/g;
$line =~ s/\</</g;
$line =~ s/\>/>/g;
# blank line = new paragraph
$line =~ s/^$/\<p\>/;
print $line;
}
}
print "\</body\>\n";
print "\</html\>\n";
dehtml.pl: strip HTML markup from a text
#!/usr/bin/perl
#strip html tags
while (<>) {
$_ =~ s/<[^>]*>//g;
print;
}
Back to the Index