RosettaCodeData/Task/Singly-linked-list-Element-insertion/Perl/singly-linked-list-element-insertion-4.pl
2023-07-01 13:44:08 -04:00

11 lines
198 B
Perl

sub insert_after {
my $node = $_[0];
my $next = $node->{next};
shift;
while (defined $_[0]) {
$node->{next} = $_[0];
$node = $node->{next};
shift;
}
$node->{next} = $next;
}