Subject: | bool overload not working |
Date: | Sat, 01 Aug 2020 14:16:51 +0000 |
To: | bug-LinkedList-Single [...] rt.cpan.org |
From: | Jörg Sommrey <jo [...] sommrey.de> |
Hi,
the bool overload does not stop at the end of the list. There is a
commented additional
condition in the source that would fix this issue, but probably would
cause some other trouble.
#!/usr/bin/perl
use strict;
use warnings;
use LinkedList::Single;
my $lh = LinkedList::Single->new(1, 2, 3);
$lh->head;
my $emergency_stop = 5;
while ($lh) {
print 'node: ', $lh->node_data, "\n";
do {print "emergency exit taken\n"; last} unless --$emergency_stop;
} continue {
$lh->next;
}
__DATA__
node: 1
node: 2
node: 3
node:
node:
emergency exit taken