in reply to how to remove similiar duplicate elements in a file/array
You want to check if you've seen the key (not the line), so the key is what you should be putting into the hash. For some definition of extract_key,
my @unique = grep { my $key = extract_key($_); ! $seen{ $key }++ } @newFile;
In this case,
my @unique = grep !$seen{ substr($_, 9, 5) }++, @newFile;
|
|---|