File: htmlcleanup2.pl

package info (click to toggle)
wp2x 2.5-mhi-10.1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 520 kB
  • sloc: ansic: 2,061; sh: 349; makefile: 113; perl: 70
file content (34 lines) | stat: -rwxr-xr-x 402 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/local/bin/perl

# things this script does:
#    1. removes consecutive <p>'s

$sawp=0;
$sawnonp=0;

while(<>) {
    if($ARGV ne $oldargv) {
	rename($ARGV, $ARGV . '.2.bak');
	open(ARGVOUT, ">$ARGV");
	select(ARGVOUT);
	$oldargv = $ARGV;
    }

    chop;

    if(/^\<[pP]\>$/) {
	if(!$sawp) {
	    print "<p>\n";
	}
        $sawp=1;
    }
    else {
	$sawp=0;
	print "$_\n";
    }

}