#!/usr/bin/perl use strict; use warnings; my (%found, @ordered_uniques); while (my $line = ) { chomp $line; next if $line !~ /\w/; # Skip non-word lines if (not exists $found{$line}) { push @ordered_uniques, $line; } $found{$line}++; } print "Ordered unique values:\n"; print (join ", ", @ordered_uniques); print "\n\nUnordered unique values:\n"; print (join ", ", keys %found); __DATA__ one foo bar one baz two quack baz