#print(STDERR "OUT $self->{OUT}\n");
for my $i (1 .. $self->{copies}) {
if ($self->{OUT}) {
- open(OUT, $self->{OUT})
- or $self->error($self->cleanup . "$self->{OUT} : $!");
+ open OUT, $self->{OUT} or $self->error($self->cleanup . "$self->{OUT} : $!");
+ print OUT while <IN>;
+ close OUT;
+ seek IN, 0, 0;
+
} else {
$self->{attachment_filename} = ($self->{attachment_filename})
? $self->{attachment_filename}
|;
- open(OUT, ">-") or $self->error($self->cleanup . "$!: STDOUT");
-
- }
-
- while (<IN>) {
- print OUT $_;
-
+ $::locale->with_raw_io(\*STDOUT, sub { print while <IN> });
}
-
- close(OUT);
-
- seek IN, 0, 0;
}
close(IN);