Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: Re: Re: using format to align

by TheDamian (Priest)
on Mar 28, 2003 at 02:15 UTC ( #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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://246384]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2017-08-23 05:44 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (347 votes). Check out past polls.