Raku / doc

🦋 Raku documentation
https://docs.raku.org/
Artistic License 2.0
292 stars 291 forks source link

Update ipc.rakudoc revise example #4511

Closed finanalyst closed 5 months ago

finanalyst commented 5 months ago

The problem

Although the example using shell works correctly, applying the comments about how to extend for repeated strings does not in fact work

Solution provided

Minimal change is to revise the comments.

The following program, which has a loop, does work. Not sure about whether to include this in the example.

use v6.d;
#| process with utility, first check it exists
my $proc = shell( <<sass --version>>, :out, :merge);
exit note 'Cannot run sass' unless $proc.out.slurp(:close) ~~ / \d \. \d+ /;
# later 
my @scss = q:to/SCSS/ , q:to/SCC2/;
    div.rendered-formula {
        display: flex;
        justify-content: space-around;
        align-items: center;
        img.logo {
            align-self: center;
        }
    }
    SCSS
    .new { color: red }
    SCC2
for @scss {
    #| set up the process for stdin
    $proc = shell( <<sass --stdin --style=compressed>>, :in, :err, :out );
    $proc.in.spurt($_,:close) ;
    say "Error: $_" with $proc.err.slurp(:close);
    say "Output: $_" with $proc.out.slurp(:close);
}
say "Sass completed";