develooper Front page | perl.perl6.users | Postings from June 2019

run with $*OUT?

Thread Next
From:
Marc Chantreux
Date:
June 6, 2019 15:01
Subject:
run with $*OUT?
Message ID:
20190606150113.GA5657@prometheus.u-strasbg.fr
hello people,

<promotion shameless>
    French Perl Workshop is coming and would be a better
    event if *you* take part of it
    https://journeesperl.fr/jp2019/talks
</promotion>

now the problem ...

let's say i have a raku script to wrap mutt.
in this script, i have

* $body is the content of the body my message
* $subject and $recipient are self explainatory

from the shell, i call mutt those ways

    mutt -s $subject $recipient <<< $body
    mutt -s $subject $recipient <<.
    $body
    .

i'm searching for the shortest/simplest way to
do that in raku (meaning stay away from react/whenever for very basic
usages) .

so it seemed to me that `run` is a good candidate
and expect filehandlers or filenames to setup the std.

i tried some variations around

    my $p = run 'cat', '-n', in => $*OUT, :out;
    $*OUT.say for < i bet on you, raku >;
    $*ERR.say: $p.out.slurp;

    my $p = run 'cat', '-n', in => "/dev/stdout", :out;
    $*OUT.say for < i bet on you, raku >;
    $*ERR.say: $p.out.slurp;

    my $o2 = $*OUT.clone;
    my $p = run 'cat', '-n', in => $o2, :out;
    $o2.say for < i bet on you, raku >;
    $*ERR.say: $p.out.slurp;

    ...

none of those made raku unhappy but none of them does the job.
i'm on my way to use Proc::Async.new ... but before that, i would like
to ask if there is a simpler solution.

regards,
marc

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About