quote qqx

Documentation for quote qqx assembled from the following types:

language documentation Quoting constructs

From Quoting constructs

(Quoting constructs) quote qqx

If one wishes to use the content of a Perl 6 variable within an external command, then the qqx shell quoting construct should be used:

my $world = "there";
say qqx{echo "hello $world"};  # OUTPUT: «hello there␤» 

Again, the output of the external command can be kept in a variable:

my $word = "cool";
my $option = "-i";
my $file = "/usr/share/dict/words";
my $output = qqx{grep $option $word $file};
# runs the command: grep -i cool /usr/share/dict/words 
say $output;      # OUTPUT: «Cooley␤Cooley's␤Coolidge␤Coolidge's␤cool␤...» 

See also run and Proc::Async for better ways to execute external commands.