|XP is just a number|
Do you use format and write?by pernod (Chaplain)
|on Mar 10, 2005 at 15:23 UTC||Need Help??|
pernod has asked for the wisdom of the Perl Monks concerning the following question:
This may be a bit rambling, but I was thinking about the Report part of Practical Extraction and Report Language today. I looked at perlform, and wondered why I don't see these features in use more often.
I started thinking about this after writing a small script that found the latest revision number of a set of .c and .h files and printed them to STDOUT. I ended up with this:
It's a quick and dirty hack that uses File::Find to find all .c and .h files below the current directory, and a regular expression to fetch some fields from the header comments. The match results are then stuffed into the predefined values that are defined in the format, and then write pushes it all out to STDOUT.
Why is the use of format so seldom seen around here at the Monastery? Is it because of the rather arcane picture syntax, or perhaps because printf and friends are simpler to use? Or something else entirely?
I find that I like formats, though. Different. Declarative. Quite concise. Good :)