Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Format question...

by Hofmator (Curate)
on Jan 07, 2003 at 19:41 UTC ( #225053=note: print w/replies, xml ) Need Help??

in reply to Format question...

Something like the following should work:
format RECEIPT_TOP = Item Quantity Price -------------------------------------------- . format RECEIPT = @<<<<<<<<<<<<<<<<<<<<< @<<<<< @####.## @format_row . for my $row_ref ( @$cartItemsRef ) { @format_row = @$row_ref; write RECEIPT; # this writes to the filehandle RECEIPT }

You can read up more on formats with perldoc perlform.

And maybe you should consider another solution altogether like using a templating system, e.g. TT2 or Text::Template.

Update: The code above only works if you retreive exactly these three columns (in the order you use them in the template) from the database. Otherwise the @format_row = ... line has to be adjusted accordingly.

-- Hofmator

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://225053]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2021-06-18 00:33 GMT
Find Nodes?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)

    Results (86 votes). Check out past polls.