In article <20020201052621.GE9474@blackrider>,
Michael G Schwern <[EMAIL PROTECTED]> wrote:
>On Thu, Jan 31, 2002 at 08:10:00PM -0800, Yitzchak Scott-Thoennes wrote:
>> In article <20020201025307.GC9474@blackrider>,
>> Michael G Schwern <[EMAIL PROTECTED]> wrote:
>> >
>> >$date = sprintf "%02d/%02d/%d", split '/', $date;
>> 
>> Perhaps slightly more efficient:
>>   $date = sprintf "%02d/%02d/%s", split '/', $date, 3;
>
>You took the hood ornament off your car to reduce drag, didn't you.

It's also functionally different.  Otherwise I wouldn't have bothered.

>> But in some ways the regexp solutions are better since they'll leave
>> more malformed strings alone.
>
>Yay!  Silently failing code!

Better something that leaves $date = 'unexpected garbage' alone than
converts it to 00/00/0.  When 'unexpected garbage' turns up in the output
at some point, you have a better chance of tracking down where it came
from.

In my first programming job, one of the more experienced programmers
taught me "never check for an error condition you don't know how to
handle."  Words to live by. :)

Reply via email to