length($a) lt 2 should be length($a) < 2. You are converting the returned length to a string and doing a lexical (not a numerical) compare.
$a = "abcdefghij"; length($a) lt 2 ==> "10" lt "2" ==> true $a = "0$a"; length($a) lt 2 ==> "11" lt "2" ==> true ... $a = "0$a"; length($a) lt 2 ==> "20" lt "2" ==> false
If length($a) starts in [0..1], the final length($a) will be 2.
If length($a) starts in [2..9], $a won't change.
If length($a) starts in [10..19], the final length($a) will be 20.
If length($a) starts in [20..99], $a won't change.
If length($a) starts in [100..199], the final length($a) will be 200.
If length($a) starts in [200..999], $a won't change.
If length($a) starts in [1000..1999], the final length($a) will be 2000.
If length($a) starts in [2000..9999], $a won't change.
If length($a) starts in [10000..19999], the final length($a) will be 20000.
etc.
This could cause thrashing with very long strings (which localtime doesn't return), but I don't see this ever creating an infinite loop.
Try using
my $min = (localtime)[1]; $min = sprintf('%02d', $min);
In reply to Re: Can scalar representation cause infinite loops?
by ikegami
in thread Can scalar representation cause infinite loops?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |