All pastes #735304 Raw Edit

Mine

public text v1 · immutable
·published 2007-10-13 14:22 UTC
rendered paste body
#! /usr/bin/perl -w
    eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
        if 0; #$running_under_some_shell

use strict;
use File::Find ();

# Set the variable $File::Find::dont_use_nlink if you're using AFS,
# since AFS cheats.

# for the convenience of &wanted calls, including -eval statements:
use vars qw/*name *dir *prune/;
*name   = *File::Find::name;
*dir    = *File::Find::dir;
*prune  = *File::Find::prune;

sub wanted;

my $flag;
my $line;
my $html_line;

my @insertion;
my @html_array;

open(INSERTION, "../insert") || die("can't open datafile: $!");


while ($line = <INSERTION>)
{
	push(@insertion ,$line);
}

my $var;

foreach $var (@insertion)
{
	print $var;
}



# Traverse desired filesystems
File::Find::find({wanted => \&wanted}, '.');
exit;


sub wanted {
    if ( -d ) {

        if ( $_ eq '.svn' ) {

# don't traverse into subversion related directories
#             $File::Find::prune = 1;
            return;
}

# for directories, only print path
#         print "$File::Find::name\n";
        return;
}

    -f            or return;  # if not a file

# print $name;
# print "\n";

my $nameExt;
my $bak;

$nameExt = $name . "_new";
print $nameExt;

$bak = "$name.bak";

open(INPUT,"< $name") || die("can't open datafile: ";
open(OUTPUT, "> $nameExt") || die("cant open temporaryfile: ";

while ($line = <INPUT>)
{
	push(@html_array ,$line);
	print $line;
}

$flag = 0;

foreach $html_line (@html_array)
{
	if ($line =~ m/Start of StatCounter Code/)
{
		$flag = 1;
}
}

foreach $html_line (@html_array)
{
	if ($html_line =~ m/body class=/)
{
	
		if ($flag != 1)
{
			print $html_line;
}
}
	
}
close(INPUT)                  or die "can't close $name: $!";
close(OUTPUT)                  or die "can't close $nameExt: $!";

rename($name, $bak)          or die "can't rename $name to $bak: $!";
# rename($nameExt, $name)          or die "can't rename $new to $old: $!";

}