Complete.Org: Mailing Lists: Archives: discussion: October 2000:
[aclug-L] Re: Formatting numbers in Perl!
Home

[aclug-L] Re: Formatting numbers in Perl!

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: <discussion@xxxxxxxxx>
Subject: [aclug-L] Re: Formatting numbers in Perl!
From: "Jeremy King" <jmking@xxxxxxxxxxxxxx>
Date: Fri, 20 Oct 2000 04:00:52 -0500
Reply-to: discussion@xxxxxxxxx

From: "Mohammad Islam" <sohel@xxxxxxxxxxxxx>
Subject: [aclug-L] Re: Formatting numbers in Perl!

> Thanks. Yea i have found some info about sprintf and alreaduy using it.
> Now how about left or right justifying? Say I have the following..
>
> 99.99 124.50 6780.98
>
> I want them to line up like this:
>
>   99.99
>  124.50
> 6780.98
>
> Can i do this with sprintf?
>

Perl has some text layout functionality built in--try searching the web (or
the camel book--Programming Perl) for info on "perl formats".  Basically,
you define a format which is a template with some fixed text and some fields
that can hold variable info.  The fields can be justified left, center and
right.  When you write to the format, your variables are plugged into the
proper fields and formatted accordingly.  Formats can be a little bit goofy
to work with, but if you want to print a report or layout some text in a
specific way, they can be very useful.

Jeremy



-- This is the discussion@xxxxxxxxx list.  To unsubscribe,
visit http://tmp2.complete.org/cgi-bin/listargate-aclug.cgi


[Prev in Thread] Current Thread [Next in Thread]