$curr = $head; my $tail; while ($curr) { my $next = $curr->{next}; $curr->{next} = $tail; $tail = $curr; $curr = $next; }