First off, nice proposal. :-) I haven't had a change to digest the
entire thing (although I did read it all), but I would like to add a few
things:

>         returns the result as a single multi-line string (in a scalar context)
>         returns the result as a list of single-line strings (in a list context)
>         prints the result to the current filehandle (in a void context).

The last one I think needs to be able to work on any filehandle via
indirect object syntax, namely:

   format $FILE  "<<<<<<<<<<<   [[[[[[[[[[[[[[[   [[[[[[[[[[",
                 $title,       $text1,           $text2;

Since many people use formats for multiple output streams, and I don't
want to be stuck with a whole bunch of:

   $DEFOUT = $STDERR;
   format ... ;
   $DEFOUT = $STDOUT;

Stuff all over my code.

Second, I think there still needs to be a way to store these formats
somehow. One nice thing about current Perl formats is being able to
declare them once at the top of the script (or module) and then calling
write at different points throughout your script. Now, perhaps the best
way to do this is by sticking your format into a simple string which you
can use later:

   my $STDOUT_FORMAT = q(<<<<<<<<<<<   [[[[[[[[[[[[[[[   [[[[[[[[[[);

And then, in your loop code, calling:

   for (@data) {
       ($a, $b, $c) = split;
       format $STDOUT_FORMAT, $a, $b, $c;
   }

Or, for a different filehandle:

   my $STDERR_FORMAT = q(<<<<<<<<<<<   [[[[[[[[[[[[[[[   [[[[[[[[[[);

   for (@data) {
       ($a, $b, $c) = split;
       format $STDERR $STDERR_FORMAT, $a, $b, $c;
   }


Which would of course call $STDERR->format($STDERR_FORMAT, $a, $b, $c);

This seems to work for me, but I'd be interested in others' feedback.

-Nate

Reply via email to