in reply to Re^2: Writing to a file using Formats
in thread Writing to a file using Formats
I hope that you also are able to use the standard command line loop I gave you to great effect during the coming years. This is a standard pattern that you will use over and over again.
When you write a "while" loop, you want the main termination condition to be right there in the while()! Not buried further on down in the guts. That's not to say that other exit conditions can't exist in the "body", just that the "normal" situation should be apparent.
The technique that I used is called the "comma operator". I guess crudely put, this is way to cram 2 or more statements into the place where normally just one would go. The truth of the while() is determined by the last comma statement, in this case whether this is a "quit" command or not.
Now, some folks go "crazy" with this comma thing. I mean you could pretty much cram 10 statements in there. That is a bad idea!
Yes, there are many fancy Perl modules for formatting text. I think that once you really understand printf() you will use either it or one of those modules and this format statement will fall by the wayside - or that's what happened in my learning experience. The format thing just didn't work out to give me as much control as I often needed.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Writing to a file using Formats
by biohisham (Priest) on Aug 04, 2009 at 22:25 UTC | |
by Marshall (Canon) on Aug 04, 2009 at 23:56 UTC | |
by biohisham (Priest) on Aug 05, 2009 at 11:26 UTC |