Michael Peppler
Sybase Consulting
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
Sybase on Linux FAQ
Sybperl FAQ
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: Eduard dot Mostert at sybase dot com
Subject: Behavior of $date->info method
Date: Jan 31 2003 3:17PM


I have stumbled across a strange behavior of the $date->info method.  Am I
missing something?  I hope not.  Anyway, when I use the method more than
once, I get "more than I asked for" - literally.  It seems that the buffer
is not fully cleared for the new result set.  Thus if the first output
string is longer than the second output string, the second result will have
the additional characters, from the first string, appended.  For example,
if you have dates that fall on a Wednesday and Tuesday, the results of
$date-info(CS_DAYNAME) will be "Wednesday" and "Tuesdayay".

The following code example:-

## Call function to connect to the ASE
my($dbh) = serv_connect($user, $pass, $serv, $prog, $host) ||
           die("\nCould not connect to server $serv. Check your parameters.

## Loop through dates to see the result from $dt->info
foreach ("2003/01/01", "2002/12/31", "2002/05/01", "2002/09/01") {
    my($dt) = $dbh->newdate($_);
    printf "%-20s %-11s %-11s\n", $dt->str,

-produce these results:

Jan  1 2003 12:00AM  Wednesday   Januarya
Dec 31 2002 12:00AM  Tuesdaya    December
May  1 2002 12:00AM  Wednesday   Maynesday
Sep  1 2002 12:00AM  Sundayday   September

In this example you will also see that "January" only have the "a" appended
and not the "ay" as I would have thought.  Has anyone experienced this
behavior before and what do you suggest to avoid it?

Thanks in advance,


Eduard Mostert

Senior Consultant
Sybase Professional Services - U.S.A. N.E. Commercial