Using $_ as the array index
#!/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; }