[Omaha.pm] printf("%02d", "2007")

Jay Hannah jhannah at omnihotels.com
Tue Apr 24 13:42:27 PDT 2007


Ran into this code today

---
unless ($a[0] =~ /^\w\w\w \d\d \d\d\d\d/) {
   die "Unrecognized date format from MS-SQL: '$a[0]'";
}
@b=split ' ',$a[0];
$key_val = sprintf("%02d%02d%02d|%s",$mon{$b[0]},$b[1],$b[2],$a[1]);
---

Does anyone else think its strange to explicitly demand that Perl ram
four digits through sprintf "%02d"?

I do.  :)

$ perl -e 'printf("%02d", "2007")'
2007

j



More information about the Omaha-pm mailing list