in reply to Adding element to Array?

Try something like this. You need a hash so that you do not store repeated elements.
#!/usr/bin/perl use strict; my %record; while (my $line = <DATA>) { $record{$line}++ if ( $line =~ /\S/ ); } print for sort keys %record; __DATA__ a b c d a a c d c