in message <[EMAIL PROTECTED]>, wrote Nikolas Britton thusly... > > On 4/25/06, Nikolas Britton <[EMAIL PROTECTED]> wrote: > > basically what I want to do: ... > > my $wordlist = "letter"; > > ## some whizbang regex that removes dupe chars > > ## from words like "alphabetically" --> "alphbeticy". > > print "$wordlist\n"; ... > This works... but it's clunky: > > my $string = "letter"; > my @chars = split("", $string); > $string = ""; @chars = sort (@chars); > foreach (@chars) { > $string .= $_; > } > $string =~ tr///cs; > print "$string";
You could combine some of the steps ... my $string = 'letter'; $string = join '' , sort split '', $string; $string =~ tr///cs; print $string; ... another but rather clunky version is ... my $string = 'letter'; { my %string; @string{ split '' , $string } = (); $string = join '' , sort keys %string; } print $string; - Parv -- _______________________________________________ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"