Two problems: (1) your "local slurp" isn't local enough, and (2) I think you misread the OP's intention --
mpapet wants to write to the "deliver" process, not read from it. (And BTW, you should indent, and be careful about how line-wrapping in code blocks is handled here at PM.)
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;
(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.)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
|
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.