[aclug-L] Re: Formatting numbers in Perl!
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
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
|
|