#! /usr/bin/perl

use File::Basename;

die "$0: missing argument\n" if @ARGV < 3;
$start = shift;
$end = shift;

foreach my $file (@ARGV) {
	if (-l $file) {
		$destfile = readlink $file;
		die "$file: $!\n" if !defined $destfile;
		unlink $file || die "$file: $!\n";
		$destfile = dirname($file) . '/' . $destfile;
		system('cp', $destfile, $file) == 0 || die "system: $!\n";
	}

	open(FILE, '+<', $file) || die "$file: $!\n";
	seek(FILE, $start, 0) || die "$file: $!\n";
	my $data;
	read(FILE, $data, $end-$start) == $end-$start || die "$file: $!\n";
	my $newdata = '';
	for (my $c = 0; $c < $end-$start; $c++) {
  	$newdata .= ~ substr($data, $c, 1);
	}
	seek(FILE, $start, 0) || die "$file: $!\n";
	print FILE $newdata;
	close(FILE);
}
