#!/usr/local/bin/perl -w use strict; open REGFILE, "projects.dat" or die "Error message here: $!\n"; open NEWFILE, "+>>subscribe.dat" or die "Error message here: $!\n"; # Rewind the file for reading seek(NEWFILE, 0, 0); # Store all lines in NEWFILE in %seen using a hash slice my %seen; @seen{} = undef; while () { if (not exists $seen{$_}) { $seen{$_} = undef; # Do your split etc here print NEWFILE $_; } } close (NEWFILE); close (REGFILE);