On 4/10/06, Mike Blezien <[EMAIL PROTECTED]> wrote:
> Hello,
>
> we're working on generating customer invoices using a text file as a template,
> then inserting the various invoice data(see below - Current View & Desired
> View). I've been trying to come up with a solution to maintain the dollar
> amounts column inline with each other, but as each line is slightly different
> in
> lenght, it's hard to maintain the amount columns inline with each other. We've
> tried variations format controls within the template, but when we insert the
> data into the template dynamically, the format isn't maintained. Is there a
> workable solution of doing this ?
>
> -----------------------------------------------------------------------------------------------------------------------
> # Current View
> 02/20/2006 Payment by PayPal from NA to NA $19.95
> 02/20/2006 Flat Rate Residential USA/Canada from 03/15/2006 to 04/14/2006
> $19.95
> 02/20/2006 Flat Rate Residential USA/Canada from 02/20/2006 to 03/14/2006
> $18.62
> 02/20/2006 Flat Rate Residential Australia from 03/15/2006 to 04/14/2006
> $29.95
> 02/20/2006 Flat Rate Residential Australia from NA to NA $27.95
> 03/15/2006 Flat Rate Residential USA/Canada from 04/15/2006 to 05/14/2006
> $29.95
>
>
> Total
> $146.37
> -------------------------------------------------------------------------------------------------
>
> # Desired View w/dollar amt's inline with each row.
> 02/20/2006 Payment by PayPal from NA to NA
> $19.95
> 02/20/2006 Flat Rate Residential USA/Canada from 03/15/2006 to 04/14/2006
> $19.95
> 02/20/2006 Flat Rate Residential USA/Canada from 02/20/2006 to 03/14/2006
> $18.62
> 02/20/2006 Flat Rate Residential Australia from 03/15/2006 to 04/14/2006
> $29.95
> 02/20/2006 Flat Rate Residential Australia from NA to NA
> $27.95
> 03/15/2006 Flat Rate Residential USA/Canada from 04/15/2006 to 05/14/2006
> $29.95
>
>
>
> Total $146.37
> ------------------------------------------------------------------------------------------------
>
> TIA,
> Mike(mickalo)Blezien
In my mail reader, at least, your desired view has the dollar amounts
on a seperate line. that's simple enough:
print "$description\n\$$amount\n";
for maintaining columns, though, see the printf and pack functions.
Both of those can help you print fixed-width fields.
Perl also has built-in forms--see the perlform perldoc.
If none of these quite meets your exact needs, CPAN also has a slew of
templating modules. Text::Template, Text::Templar,
Text::SimpleTemplate, Text::ScriptTemplate, and Text::MicroMason would
all solve your problem in differnt ways depending on how and where you
want to handle the logic and text programatically.
HTH,
-- jay
--------------------------------------------------
This email and attachment(s): [ ] blogable; [ x ] ask first; [ ]
private and confidential
daggerquill [at] gmail [dot] com
http://www.tuaw.com http://www.dpguru.com http://www.engatiki.org
values of β will give rise to dom!