All pastes #242811 Raw Edit

Anonymous

public text v1 · immutable
·published 2006-11-07 19:00 UTC
rendered paste body
#!/bin/perl
my @file;
my %last_file;

foreach my $file (sort @ARGV) {

    open(F,"<$file") or die;
    @file = <F>; 
    close(F);

    if (keys %last_file) {
	rename($file,"$file.bak");
	open(F,">$file") or die;
	foreach my $line(@file) {
	    print F $line unless exists $last_file{$line};
	}
	close(F);
	unlink("$file.bak");
    }
    %last_file = ();
    @last_file{@file} = 1;
}