Thread merge strings
(20 answers)
Opened by roooot at 2009-04-09 15:27
Ich bin vielleicht etwas altmodisch:
Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 #!/usr/bin/perl use warnings; use strict; my $s1 = 'abcdef'; my $s2 = 'efghijk'; my $s = $s1 . $s2; my $a; my $i; my $m = ""; for ($i = 0; $i < length($s); $i++) { $a = substr($s, $i, 1); if ($m !~ m/\Q$a\E/) { $m .= $a; } } print "$m\n"; Gruß Last edited: 2009-04-10 02:06:23 +0200 (CEST) |