Perl and the Y2k problem - page 4
Doomsayers everywhereNow, what about Perl? Is Perl ``Year 2000 Compliant''? The answer is that Perl is every bit as Y2K compliant as is your pencil; no more, and no less. Does that comfort you? It shouldn't. Just as you can commit Y2K transgressions with your pencil, so too you can do so with Perl--or with any other tool, for that matter. You don't really even have to go very far out of your way to do so; witness the demonstration of the perfectly compliant cal program provided above.
The year returned by these functions (when used in list context) is, contrary to popular misconception, not by definition a two-digit year. Rather, it merely happens to be such right now. What it actually is, is the current year minus one thousand nine hundred. For years between 1900 and 1999 this happens to be a 2-digit decimal number, but that's not going to last long. To avoid the year 2000 problem, simply do not treat the year as a 2-digit number. Easy to say, and easy to break. Imagine that you want find out what the year appears to be in five years, so you write code like this.
use Time::localtime; $then = time() + ( 60 * 60 * 24 * 365 * 5 ); # 5 years from now $that_year = localtime($then)) -> year; printf("It shall be 19%d\n", $that_year); # WRONG! 19103 printf("It shall be %d\n", 1900 + $that_year); # right: 2003
As you see, in the wrong hands, even a nominally year 2000 compliant tool such as Perl or cal can be misused by the underclued or simply the forgetful.
Executive summary from TPI, The Perl Institute:
Perl has no warranty, and TPI does not support Perl. Furthermore, Perl is a language, and languages can be misused in many ways. But that's the responsibility of the programmer and the user, not of the many creators of Perl. Nevertheless, as spokes-organization for the Perl freeware movement, we feel compelled to point out that Perl is every bit as Y2K compliant as the C language upon which its interfaces are based, and in which the Perl compiler and interpreter are themselves written. That is, the interfaces giving access to date information in Perl, when used as designed, are Y2K compliant in every sense of that word.
If that makes your lawyers or managers happy, well, good for them. You still have a lot to worry about.
If you can think of any way to make this message more helpful, please let me know. I apologize in advance if this message comes off sounding unkind to you; it wasn't meant to be. I'm honestly just trying to help to make the Net a better place for all of us.
Solid state disks (SSDs) made a splash in consumer technology, and now the technology has its eyes on the enterprise storage market. Download this eBook to see what SSDs can do for your infrastructure and review the pros and cons of this potentially game-changing storage technology.
- 1Linux Top 3: GNOME 3.12 and New Betas for Ubuntu 14.04 and OpenMandriva Lx 2014.0
- 2Linux Top 3: Linus Lashes out, Linux 3.14 Gets PIE and Ubuntu One is Done.
- 3Linux Top 3: Ubuntu 14.04, Debian Gives Squeeze More Life and Red Hat Goes Atomic
- 4Linux Top 3: RHEL 6.5, Debian 7.2 and EOL for Linux 3.0.x
- 5Linux Top 3: CoreOS, Oracle Enterprise Linux 7 and Ubuntu 14.10