Leser: 1
|< 1 2 >| | 12 Einträge, 2 Seiten |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
#!/usr/bin/perl -w @konsonants = ( "p", "b", "t", "d", "k", "g", "m", "n", "f", "v", "h", "ch", "l", "r", "s", "sch", "ts", "ds", "tsch", "dsch", "x" ); #21 @not_first = ( "p", "b", "t", "d", "k", "g" ); #6 @not_second = ( "p", "b", "t", "d", "k", "g", "m", "n", "ts", "ds", "tsch", "dsch", "x" ); #13 $j = 0; $konso1 = 0; $konso2 = 0; $len_not_first = @not_first; $len_not_second = @not_second; # CC foreach $konso1 (@konsonants) { foreach $konso2 (@konsonants) { if ($konso1 eq $konso2) { next } for ($i = 0; $i < $len_not_first; $i++) { for ($y = 0; $y < $len_not_second; $y++) { if ($konso1.$konso2 ne $not_first[$i].$not_second[$y]) { next } # if ($konso1 ne $not_first[$i]) { } # elsif ($konso2 ne $not_second[$y]) { } else { print $konso1.$konso2."\n"; $j++; } } } } } print $j; print "\n";
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#!/usr/bin/perl -w use strict; my @konsonants = qw( p b t d k g m n f v h ch l r s sch ts ds tsch dsch x ); #21 my @not_first = qw( p b t d k g ); #6 my @not_second = qw( p b t d k g m n ts ds tsch dsch x ); #13 foreach my $konso1 (@konsonants) { next if ( grep { $konso1 eq $_ } @not_first ); foreach my $konso2 (@konsonants) { next if ( $konso1 eq $konso2 ); next if ( grep { $konso2 eq $_ } @not_second ); print $konso1, $konso2, $/; } }
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 -w use strict; my @konsonants = qw( p b t d k g m n f v h ch l r s sch ts ds tsch dsch x ); #21 my @not_first = qw( p b t d k g ); #6 my @not_second = qw( p b t d k g m n ts ds tsch dsch x ); #13 my $j = 0; foreach my $konso1 (@konsonants) { foreach my $konso2 (@konsonants) { next if ( $konso1 eq $konso2 ); if ( grep { $konso1 eq $_ } @not_first ) { next if ( grep { $konso2 eq $_ } @not_second ); } print $konso1, $konso2, $/; $j++; } } print $j;
Linuxer+2008-08-07 19:17:32--Code (perl): (dl )print $konso1, $konso2, $/;
bloonix+2008-08-08 13:43:54--Linuxer+2008-08-07 19:17:32--Code (perl): (dl )print $konso1, $konso2, $/;
$/ hier zu verwenden halte ich für ziemlich schmutzig!
Linuxer+2008-08-08 14:10:38--bloonix+2008-08-08 13:43:54--Linuxer+2008-08-07 19:17:32--Code (perl): (dl )print $konso1, $konso2, $/;
$/ hier zu verwenden halte ich für ziemlich schmutzig!
Steht Dir frei. Aber erwarte von mir nicht, dass ich mir davon was annehme, wenn Du mir keine Erklärung dazu lieferst.
1 2 3 4
local $\ = $/; # ausserhalb der Schleifen [...] print $konso1, $konso2; # $\ wird automatisch am Ende angehängt
Quote$/
The input record separator, newline by default. This influences Perl's idea of what a "line" is. Works like awk's RS variable, including treating empty lines as a terminator if set to the null string. (An empty line cannot contain any spaces or tabs.) You may set it to a multi-character string to match a multi-character terminator, or to undef to read through the end of file. Setting it to "\n\n" means something slightly different than setting to "" , if the file contains consecutive empty lines. Setting to "" will treat two or more consecutive empty lines as a single empty line. Setting to "\n\n" will blindly assume that the next input character belongs to the next paragraph, even if it's a newline. (Mnemonic: / delimits line boundaries when quoting poetry.)
...
Setting $/ to a reference to an integer, scalar containing an integer, or scalar that's convertible to an integer will attempt to read records instead of lines, with the maximum record size being the referenced integer.
|< 1 2 >| | 12 Einträge, 2 Seiten |