programming-examples/perl/Statement/Each time through the loop, foreach places the next element of the list into the scalar variable.pl

13 lines
225 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
#!/usr/bin/perl -w
@languages = ("A","C","D","B","A");
foreach $subLang (@languages) {
if ($subLang eq "Perl") {
print "Perl is $subLang.\n";
} else {
print "$subLang ideas.\n";
}
}