http://www.perlmonks.org?node_id=442198

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

First off, I know that formats are not the preferred method for formatting text. What can I say, mea culpa.

However, I recently ran into a situation where the easiest way to go from problem to solution, on a one-use-script, was to use a format. However, I ran into the problem that I had to comment out "use strict" in order to get my code to compile. At least I had this problem if I used a format name other than "STDOUT"...

Is there something I am missing? Consider the following trivial code. Is there some way to use both the format and to get "use strict" to work?

#!/usr/bin/perl -w use strict; my $text1 = "A"; my $text2 = "B"; $~ = COLUMNS; write; exit; format COLUMNS = @<<<<<<@>>>>>>> $text1,$text2 .

Replies are listed 'Best First'.
Re: "use strict" and formats
by Joost (Canon) on Mar 24, 2005 at 21:39 UTC

      Darn. I knew it had to be something simple that I was missing. I just couldn't find anything with any searches - presumably because the terms "use strict" and "format" are too general. Anyway, here's hoping that at least some other obsessive-compulsive person will be able to find my question and your answer.

      Thanks Joost!!

      (Update)FWIW, being a noob to this site (first post ever) I didn't realize it is somewhat of a faux pas to create a new post saying "thanks". Personally - I think one "thank you" lets the person which replied know that their answer was used. More than once I've posted replies (elsewhere), and had absolutely no idea whether the original poster even read my reply, never mind whether it worked or no. One way I suppose I can make this rambling cruft a bit more worthwhile is to humbly request a pointer to where the correct answer is documented, so that I don't have to ask silly questions like this again.

      (Update - Update)Found the thread regarding "perldoc" not too long after posting my first update (where I read about "thanks"). Too bad I didn't know about perldoc a bit sooner - my GoogleFoo wouldn't have taken such a beating. Thanks nonetheless schodckwm.

        Not a silly question...
            perldoc -f format

        But... (addressing silliness of not knowing) make yourself familiar with perldoc for general answers to similar questions. You may want to start with
            perldoc -h | more or
            perldoc perldoc and work from there.