my %set #how you initialize an array while($line=<>) #while text is coming in from the keyboard #set $line=line of keyboard input { unless($set{$line}){ $set{$line}=1; # basically means we've seen this line } } #now lets see each $line we've encountered foreach my $line(keys %set){ print $line; }