Here is my situation.
sub listing_out # override this for your desired output format { my ($self, $output, $starting, $count, $file, $line, $text)= @_; # I guess I really should learn something about the old formatting st +uff! print {$output} "[$starting] "; foreach my $i (0..$count) { print {$output} " $self->{PROGRAM}[$starting+$i]"; } print {$output} "\t$text\n"; }
The middle column can be of varing length, depending on how much was on that source line and of what complexity. But I want the text listing to line up with itself, starting at some fixed column.
If the middle column is longer than planned, wrap it onto multiple lines.
So, this sounds like a job for format I thought!
I start reading about write and it mentions the current format attached to the file handle but that it can be selected. I then turn to perlform and the first thing it says is that format takes a NAME.
Well, I immediatly see a mismatch between this classic stuff and modern programming. My function takes a parameter for an output handle, and it might not even be a named HANDLE thing.
Is perl formats the way to go here, or should I just leave it in the past? What should I use?
—John
In reply to To format or not? by John M. Dlugosz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |