programming-examples/perl/Statement/Using foreach to iterate over an array.pl

7 lines
207 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
@array = ( 1 .. 10 ); # create array containing 1-10
foreach $number ( @array ) { # for each element in @array
$number **= 2; # square the value
}
print "@array\n";