Skip to Content
Perl Debugged
book

Perl Debugged

by Peter Scott, Ed Wright
March 2001
Intermediate to advanced
288 pages
4h 56m
English
Addison-Wesley Professional
Content preview from Perl Debugged

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Perl Hacks

Perl Hacks

Chromatic, Damian Conway, Curtis Ovid Poe, Curtis (Ovid) Poe
Pro Perl

Pro Perl

Peter Wainwright
Intermediate Perl

Intermediate Perl

Randal L. Schwartz, brian d foy, Tom Phoenix
Perl Testing: A Developer's Notebook

Perl Testing: A Developer's Notebook

Ian Langworth, Chromatic

Publisher Resources

ISBN: 0201700549Purchase book