#!/usr/bin/perl -w use strict; my @comp = split /:/,shift; my %saw = (); my @out = (); for (@comp) { push @out,$_ unless $saw{$_}++; } print join ":",@out;