I didn't think it's possible and the trick is to shell out the writing and opening to a shorter syntax.
This might be considered dirty in a real Perl script but should be acceptable in a one-liner. And interestingly it should also work on windows.
Point is Perl has no mean to print_and_open_if_necessary()
So the next step is to ask myself if the semantics could be cleanly replicated in Perl...
IMHO a tied hash %FH would be most elegant
print $FH{">>$name"} $value
I didn't try to search CPAN for similar solutions yet, cause I'm not sure how.
Comments welcome. ..
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
In reply to Re^2: Split tab-separated file into separate files, based on column name (open on demand)
by LanX
in thread Split tab-separated file into separate files, based on column name
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |