in reply to Question on the format statement

Of course, that is what it is designed for. Here is a simple example:
open (REPORT, '>', 'report.txt') || die "Can't open report.txt: $!"; write REPORT; format REPORT = @<<<<<<< @>>> @<<<<<<<<<<<<<<<<<<<<<<<< $var1, $var2, $var3 .
I have to admit that I have been unable to get format to work with lexical file handles.

Replies are listed 'Best First'.
Re^2: Question on the format statement
by chromatic (Archbishop) on Mar 31, 2010 at 22:00 UTC
    I have to admit that I have been unable to get format to work with lexical file handles.

    You have to localize the appropriate typeglob, then assign the lexical filehandle to the glob. It's a workaround, but formats don't work with lexical filehandles. They get bound to typeglobs.