in reply to Re: $" seems not to be working
in thread $" seems not to be working

<nitpick>

Might as well make the code as generic as possible ...

#! perl -slw use strict; my %fhs; my $d = '|'; while(<>) { my ($first, $rest) = m[(^.*?)\Q${d}\E(.*$)]; open $fhs{$first}, '>>', $first or die "Couldn't open $first:$!" unless $fhs{$first}; print { $fhs{$first} } $rest; }
Of course, if you didn't need those curlies, the code would look even better ...
#! perl -slw use strict; my %fhs; my $d = '|'; while(<>) { my ($first, $rest) = m[(^.*?)\Q${d}\E(.*$)]; my $fh = $fhs{$first} ||= do { IO::File->new('>>', $first) || die "Couldn't open $first:$!" }; $fh->print($rest); }
</nitpick>

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.