in reply to Re^2: Deleting duplicate lines from file
in thread Deleting duplicate lines from file

Also

@unique{@lines} = ();

since you don't use the values anyway.

Actually, it does need true values for each key or delete will return false. So, while it's true it doesn't use them, it does need them.

  • Comment on Re^3: Deleting duplicate lines from file

Replies are listed 'Best First'.
Re^4: Deleting duplicate lines from file
by blazar (Canon) on Feb 17, 2006 at 16:05 UTC

    Fair enough. I hadn't noticed. And in a certain sense it does use them. Whatever, since your proposed solution

    do { print if delete $unique{$_} } for @lines;

    although perfectly working is not that intuitive and I seem to remember that deleting elements has an effective execution load, I'd still stick with a %saw-like solution. But I admit that all in all yours is an interesting and smart use of delete.