in reply to Removing duplicate lines based on a match
Context problem aside, it's usually better* to use a while loop and process your input line-by-line rather than slurping the entire file into an array.
while( my $line = <FILE> ) { ## ... }
Your sysadmin and the other users on the box will thank you when input.txt grows to 800M and you don't send the OS thrashing because you've got it all resident in memory.
(*: FSVO "better", of course. Yes it may be fine in this particualr case and this set of inputs will neber eber grow that large fer sure. Really. But you'll be better served by developing a habit of defaulting to line-by-line and only slurping out of conscious choice after looking at the problem.)
The cake is a lie.
The cake is a lie.
The cake is a lie.
|
|---|