use warnings; use strict; my %seen; print sort grep !$seen{$_}++, __DATA__ c c b c b b a c a b