# the imperative way to build a list of the squares of the integers 
# 1 .. 10
my @range = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);

my @squares = ();
foreach my $x ( @range ) {
    push @squares, $x * $x;
    }
print("@squares\n");
     
# the functional way using list comprehension.  The expression x**2 is
# mapped over the list [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
@squares = map { $_ * $_ } @range;
print("@squares\n");
