#!/usr/bin/perl use strict; use warnings; my $string = 'one bright day in the middle of the night'; my (%seen, $new_string); for ( split // , $string ) { next if $seen{$_}; $seen{$_}++; $new_string .= $_; } print "$new_string\n";