#!/usr/bin/perl @names = ('jack', 'janet', 'chrissy'); # alternate notation for strings: @names = qw( jack janet chrissy ); $names[2] = 'cindy'; $names[4] = 'terry'; # also creates an undefined item at position 3 print "@names\n"; @names = qw( jack janet chrissy ); $gone = pop(@names); push(@names,'cindy'); print @names, "\n"; @list = @names; # a list of names $n = @names; # the length of the list @names (e.g., 3) print "@list\n"; print "$n\n"; @short = 3*5; # is a one-element list (15) print "@short\n"; print 15 != @short, "\n"; ########## foreach $person (@names) { print "My favorite cast member is $person\n"; } # Or, using the special default variable: foreach (@names) { print "My favorite cast member is $_\n"; } ########## for ($i = 1; $i <=10; $i++) { print "The current value is $i\n"; } # same as: $i = 1; while ($i <=10) { print "The current value is $i\n"; $i++; } ########## print "Enter an integer:\n"; chomp($a = ); if ($a < 1) { $b = 'below'; } elsif ($a > 1) { $b = 'above'; } else { # note that we assume $a is an number $b = 'one'; } print "$b\n"; ########## @lines = ; chomp(@lines); foreach $line (@lines) { print "Your line was: '$line,' wasn't it?\n"; }