in reply to Re: Newbie: Pipe/STDIN Clarification
in thread Newbie: Pipe/STDIN Clarification

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.)

Replies are listed 'Best First'.
Re^3: Newbie: Pipe/STDIN Clarification
by mrstlee (Beadle) on Nov 05, 2011 at 16:29 UTC
    Ah - but as you say I misread the OP's intention. The localised slurp also encompassed the (incorrectly) assumed read from the command - which I assumed would come with line feeds.

    Thanks for the tip on indents.