programming-examples/perl/Statement/Using variable defined outside in foreach loop.pl

10 lines
173 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
#!/usr/bin/perl -w
use strict;
my @array = (1, 3, 5, 7, 9);
my $i = "Hello there";
foreach $i (@array) {
print "This element: $i\n";
}
print "All done: $i\n";