use strict;
my $list = undef;
for (reverse 0..10){
$list = [$list, $_ * $_];
}
sub walk_list {
my $head = shift;
my $steps = shift;
my $action = shift;
while ( $steps && $head->[0] ){
$action->($head);
$head = $head->[0];
$steps--;
}
}
my $print_list = sub {my $node = pop; print $node->[1], "\n";};
walk_list($list, 10, $print_list);