diff options
| -rwxr-xr-x | challenge-071/jo-37/perl/ch-2.pl | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/challenge-071/jo-37/perl/ch-2.pl b/challenge-071/jo-37/perl/ch-2.pl index 5dde4091a1..6767dbe061 100755 --- a/challenge-071/jo-37/perl/ch-2.pl +++ b/challenge-071/jo-37/perl/ch-2.pl @@ -28,8 +28,8 @@ sub remove_from_end { # Process all nodes but the last from the original list. for ($list->head; $list->has_next; $list->next) { - # Record the position and skip over the new node. - $record->add($list->node)->next; + # Record the position. + $record->push($list->node); # Discard the first recorded position if the maximum length # is exceeded. @@ -41,8 +41,7 @@ sub remove_from_end { # If $n is large enough, the root_node is still the first node # of the record list causing the first node of the original list # to be cut. - my $node = $record->head->node_data->[0]; - $list->node($node); + $list->node($record->head->node_data->[0]); $list->cut; $list; |
