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

run with $*OUT?

Thread Next
Marc Chantreux
June 6, 2019 15:01
run with $*OUT?
Message ID:
hello people,

<promotion shameless>
    French Perl Workshop is coming and would be a better
    event if *you* take part of it

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

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 ... but before that, i would like
to ask if there is a simpler solution.


Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About