programming-examples/perl/Statement/foreach and array.pl

12 lines
320 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
#!/usr/bin/perl
$str="hello";
@numbers = (1, 3, 5, 7, 9);
print "\$str is initially $str.\n";
print "\@numbers is initially @numbers.\n";
foreach $str (@numbers ){
$str+=5;
print "$str\n";
}
print "Out of the loop--\$str is $str.\n";
print "Out of the loop--The array \@numbers is now @numbers.\n";