programming-examples/perl/Statement/Using predefined variable $_ in foreach loop.pl

13 lines
163 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
#!/usr/bin/perl -w
use strict;
my @array = (10, 20, 30, 40);
print "Before: @array\n";
foreach (@array) {
$_ *= 2;
}
print "After: @array\n";