in reply to Why does this hash remove duplicate lines

an interesting technique but all it amounts to is testing for the existence of a hash element, which can also be done (perhaps more intuitively) thus:

my %lines; while (<DATA>) { unless (exists($lines{$_})) {print "$_"} $hash{$_}="done"; # element defined }

Replies are listed 'Best First'.
Re^2: Why does this hash remove duplicate lines
by olus (Curate) on Mar 06, 2008 at 11:38 UTC

    Nice try, but you should have tested it? %lines and %hash are two different hashes :). strict and warnings would have told you that.