Robert's Perl Tutorial

http://www.sthomas.net/roberts-perl-tutorial.htm


foreach

For true beauty we must use foreach .

foreach $person (@names) {
        print "$person";
}

This goes through each element ('iterates', another good technical word to use) of @names , and assigns each element in turn to the variable $person . Then you can do what you like with the variable. Much easier. You can use

for $person (@names) {
        print "$person";
}

if you want. Makes no difference at all, aside from a little clarity.