Thread Zahlenkolonnen in ein Array erweitern...
(14 answers)
Opened by pemi79 at 2010-06-08 16:55 Code (perl): (dl
)
1 2 3 4 5 6 7 8 my @ranges = map { $_->[0] .. $_->[1] } map { my ($x, $y) = split /-/, $_; $y //= $x; # in perl < 5.10 muss es lauten: $y = $x unless defined $y; [$x,$y] } split / /, $_; print "Zahlen: @ranges\n"; Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. -- Damian Conway in "Perl Best Practices"
lesen: Wie frage ich & perlintro brian's Leitfaden für jedes Perl-Problem |