Thread Codereview (11 answers)
Opened by Kuerbis at 2013-05-23 10:29

Kuerbis
 2013-05-23 10:29
#167757 #167757
User since
2011-03-20
943 Artikel
BenutzerIn
[default_avatar]
Hallo!

Ist es hässlich eine Zahl mit dem . (string concatenation) zusammen zubauen anstatt es zu machen, wie im ersten Beispiel?

Code (perl): (dl )
1
2
3
4
5
6
7
8
my $x = 0;
my $c;
while ( 1 ) {
    $c = ReadKey 0;
    last if $c !~ /^[0-9]$/;
    $x = 10 * $x + $c;
}
return -1 if $c ne ';';


Code (perl): (dl )
1
2
3
4
5
6
7
8
my $c = ReadKey 0;
my $x = '';
while ( 1 ) {
    last if $c !~ /^[0-9]$/;
    $x .= $c;
    $c = ReadKey 0;
}
return -1 if $c ne ';';

View full thread Codereview