in reply to Automatic generation of textfiles

If I understand you correctly, then what you're asking for is known in the Unix world as "tee". I remember having seen several solutions to solve this neatly, in Perl. In fact, it's even in the official perlfaq:
How do I print to more than one file at once?