mikejones has asked for the wisdom of the Perl Monks concerning the following question:

Does anyone see anything wrong with this code? If I comment the format code out, my program works fine and since I am new to using format I would like some help.

thank you

##-- Begin Format Code --## format STDOUT_TOP = Page @<<< $% FileName Owner GroupOwner LastModifiedDate Size ========= ======= =========== ================= ===== . format STDOUT = @* @>>>>>>> @>>>>>>>> @################## @##.### $key, $user, $grp, $mod, $sz . ##-- End Format Code --##
The errors I am getting are:
Format not terminated at find_hog line 106, at end of line Missing right curly or square bracket at find_hog line 106, at end of +line syntax error at find_hog line 106, at EOF find_hog had compilation errors.

Replies are listed 'Best First'.
Re: format issues
by NetWallah (Canon) on Jan 04, 2008 at 05:39 UTC
    From "perldoc perlform" (emphasis is mine):
    A single "." in column 1 is used to terminate a format.
    Your format-terminating period appears to be in column 8.

         "As you get older three things happen. The first is your memory goes, and I can't remember the other two... " - Sir Norman Wisdom

      When the format statement is parsed it will run right through to end-of-file (or __END__) looking for the . in column 1. You can't "scope" format statements, and you can't indent them, so I find they are best placed in a section of the file on their own at the front or end, outside of subroutines.