All pastes #897448 Raw Edit

Something

public html v1 · immutable
·published 2008-02-09 15:55 UTC
rendered paste body
I have written the following code to create a simple linked list, and walk through it, printing each element:<br><br><code><pre>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);</pre></code><br>Two questions:<br><br>1) Why does it only print up to 81 instead of the expected 100?<br>2) Why does the anonymous sub that I currently have in <b>$print_list</b> work fine, however this:<br>