in reply to Re: Newbie: Pipe/STDIN Clarification
in thread Newbie: Pipe/STDIN Clarification
(Updated to use lexically-scoped file handle in the localized input block -- that's what will cause the file to be closed on leaving the block.)my $stringified; { local $/; # defaults to undef open my $fh, '<', './demo.mail'; # 3-arg open is nice $stringified = <$fh>; } # input's done, end-of-block closes the file and reverts to normal i/o my @cmd = qw( /usr/lib/dovecot/deliver -f test@somedomain.com -d test@mailtask.dom ); open( CMD_OUT, '|-', @cmd ) or die $!; print CMD_OUT $stringified; close CMD_OUT;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Newbie: Pipe/STDIN Clarification
by mrstlee (Beadle) on Nov 05, 2011 at 16:29 UTC |