use strict; my %guard; my @unique; while (<>) { chomp; push @unique,$_ if (!exists $guard{$_}); $guard{$_} = 1; } print join(" ",@unique),"\n";