10.3. But What Did It Mean?

The following program is designed to reprint its input lines prefixed with an increasing date that skips weekends:

#!/usr/bin/perl -w
use strict;
use Time::Local;
my $t = timelocal(0,0,0,31,11,99);   # Dec 31 1999
while (<>)
   {
   my ($m, $d, $y) = (localtime $t)[4,3,5];
   $y %= 100;
   $m++;
   print "$m/$d/$y $_";
   dp { $t += 86400 } while (localtime $t)[6] == 0
                         || (localtime $t)[6] == 6;
   }

However, the output shows a date that doesn't change:

12/31/99 This is the first line
12/31/99 This is the second line
12/31/99 This is the third line

Running under the debugger won't reveal anything other than the fact that $t isn't being increased in the do block.

Wait a minute. It doesn't say do, does it? It's a typo: dp. Yes, we could ...

Get Perl Debugged now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.