programming-examples/perl/Statement/Using array length in foreach statement.pl

13 lines
241 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
#!/usr/bin/perl -w
use strict;
my @questions = qw(Java Python Perl C);
my @punchlines = ("A","B","C",'D');
foreach (0..$#questions) {
print " $questions[$_] ";
sleep 2;
print $punchlines[$_], "\n\n";
sleep 1;
}