Thread Beispiel in List::MoreUtils (1 answers)
Opened by Gast at 2008-12-06 11:43

Gast Gast
 2008-12-06 11:43
#116870 #116870
Am Ende von "apply BLOCK LIST" steht:

Code: (dl )
Think of it as syntactic sugar for

Code (perl): (dl )
for (my @mult = @list) { $_ *= 2 }


Bei mir funktioniert das nur, wenn ich das so schreibe:

Code (perl): (dl )
1
2
my @mult = ();
for (@mult = @list) { $_ *= 2 }


z.B.

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/bin/perl
use strict;
use warnings;



my @list = ( 1..10 );
my @mult = ();

  
for ( @mult = @list ) { $_ *= 2 }


print "$_\n" for @mult;

View full thread Beispiel in List::MoreUtils