SPUG: Dates, anyone?
Steve Laybourn
otter101 at hotmail.com
Mon Jan 3 19:51:17 CST 2000
G'day, all!
Well, my little code snippet to deal with date formatting seems to have
stirred up a little excitement...but I don't think you would have wanted to
see the whole of that package (Date::Calendrica, soon to be featured on a
CPAN near you!) just to get at that little snippet!
I like this group!
OK, let's do another one...
Currency functions! Everyone doing e-commerce programming needs or
hand-rolls one of these type of functions, my own of which follows here:
sub Cur {
$ix=@_[0];
$ix=~ s/[^0123456789\.]//g;
($ix1,$ix2)=split(/\./,$ix);
if (length($ix2)==0) { $ix2="00"; }
if (length($ix2)==1) { $ix2="0"."$ix2"; }
if (length($ix2)>3) { $ix2=substr($ix2,0,3); $ix2+=5; $ix2=substr($ix2,0,2);
}
$ix3=int(length($ix1)/3);
$ix4=length($ix1)%3;
$ix5=substr($ix1,0,$ix4);
for($ix6=0;$ix6<$ix3;$ix6++) {
$ix5.=",".substr($ix1,((3*$ix6)+$ix4+1),((3*$ix6)+$ix4+3)); }
$final="\$"."$ix5".".$ix2";
return ($final); }
This is somewhat shortened from the original I'd written, but it seems to
deal with numbers in a xxxx(...)xxx.xxx(xxx)... format well enough.
I'll just bet you aces can make this work better...
Be seeing you,
Steve Laybourn
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe
Email to majordomo at pm.org: ACTION spug-list your_address
More information about the spug-list
mailing list