in reply to Remove repeated characters from a string
Cheers - L~R#!/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";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re:^2 Remove repeated characters from a string
by Anonymous Monk on May 13, 2004 at 14:47 UTC | |
by Limbic~Region (Chancellor) on May 13, 2004 at 14:54 UTC | |
by CountZero (Bishop) on May 14, 2004 at 05:29 UTC |