perl -d -l -MDate::Manip -e 'Date_Init("Internal=1"); print Date_NextW +orkDay(ParseDate("today"), ParseDate("today"))'
In a recent Perl, it loops for a long time, and eventually returns with
ERROR: Invalid year (10000)
This is the important part of the debugging session:
DB<2> l 3558: while ($off>0) { 3559: while (1) { 3560: $date=&DateCalc_DateDelta($date,"+0:0:0:1:0:0:0",\$err,0 +); 3561: last if (&Date_IsWorkDay($date,$time)); 3562 } 3563: $off--; 3564 } 3565 3566: return $date; 3567 } DB<2> c 3558 Date::Manip::Date_NextWorkDay(/home/legacy/perl/lib/site_perl/5.8.3/Da +te/Manip.pm:3558): 3558: while ($off>0) { DB<3> x $off 0 20131016053748 DB<4> print "Greater" if $off>0; Greater DB<5> s Date::Manip::Date_NextWorkDay(/home/legacy/perl/lib/site_perl/5.8.3/Da +te/Manip.pm:3566): 3566: return $date; DB<5> use Devel::Peek; print Dump $off; SV = PVMG(0x87f2fb0) at 0x84b42e8 REFCNT = 2 FLAGS = (PADBUSY,PADMY,NOK,POK,pIOK,pNOK,pPOK) UV = 4294967295 NV = 20131016053748 PV = 0x87f2eb8 "20131016053748"\0 CUR = 14 LEN = 15
The question is: does anyone remember a bug in Perl similar to this? It looks like $off was erroneously treated as negative in the underlying C, but I am not sure.
In reply to Loop Not Entered by choroba
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |