in reply to Search and replace

This should do the trick (though I don't know how efficient it is):
open OUT, ">filename" or die "can't open file for writing: $!"; while (<DATA>) { my ($one, $two) = m|##(\d{4,4})## *(\d{4,4})|; print OUT $_ unless $one == $two; } __DATA__ REG-NZL-PUB.1981-263 ##1981## 19810922
You'll have to modify it to use your filehandle (instead of <DATA>) that you open to read from.