Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Re: Re: using format to align

by TheDamian (Vicar)
on Mar 28, 2003 at 02:15 UTC ( [id://246384]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: using format to align
in thread using format to align

As rinceWind said (and as Larry made official in Apocalypse 6), in Perl 6 formats are being reworked under my evil influence. For a taste of what they'll be like, see the Text::Reform module.

Using that module, your table would be generated like so:

use Text::Reform; my @name = qw(foo foo2 foo3); my @last = qw(bar bar2 bar3); my @count = qw( 3 4 5 ); print form "--------------------------------------------------", "NAME LAST COUNT", "--------------------------------------------------", "[[[[[[[[[ [[[[[[[[[[[[[[[[[[ |||||", \@name, \@last, \@count;
Or, if your data was likely to spill over multiple pages, you might prefer more sophisticated headers and footers:
use Text::Reform; my @name = (qw(foo foo2 foo3)) x 20; my @last = (qw(bar bar2 bar3)) x 20; my @count = (qw( 3 4 5 )) x 20; print form { header => "--------------------------------------------------\n" . "NAME LAST COUNT\n" . "--------------------------------------------------", footer => sub { my ($pagenum, $lastpage) = @_; return "\n\n\nEND OF REPORT" if $lastpage; form "\n\n\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", ".../".($_[0]+1); }, pagelen => 20, pagefeed => "\n\n".("_"x60)."\n\n", }, "[[[[[[[[[ [[[[[[[[[[[[[[[[[[ |||||", \@name, \@last, \@count;
Note in particular the use of a (conditional, nested) call to form within the footer of the main form.

The Perl 6 format syntax will be even more sophisticated than that provided by Text::Reform, since I'll be taking advantage of new features of Perl 6. For example, the named options that control headers/footers/etc won't need to be in hashes, and array arguments won't require an explicit backslash.

There will also be additional formatting modes and options, all of which will eventually be described in Exegesis 7.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-24 11:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found