This is very similar to a question answered in perldoc perlfaq5, namely How do I print to more than one file at once?.
If you open multiple filehandles and add everything to one big string, it's easy to write a loop. The other suggestions depend on being able to install stuff locally or having Unix commands available.
The IO::Tee module on the CPAN is another solution. | [reply] |
There are probably a lot of ways to do what you're looking to do, but unfortunately no one is going to be able to give you the best way without seeing your code.
But without seeing it, you could do several things. One would be to put all the lines to be printed into an array and then pass that array to a sub to print it and then a sub to mail it. Another would be to do both at the same time as the text is generated or evaluated. This all really depends on the overall scope of what you're doing though.
Rich | [reply] |