Skip to content

Instantly share code, notes, and snippets.

@AlexDaniel
Created October 3, 2015 11:08
Show Gist options
  • Save AlexDaniel/176da249d1314b8cf3a9 to your computer and use it in GitHub Desktop.
Save AlexDaniel/176da249d1314b8cf3a9 to your computer and use it in GitHub Desktop.
Perl6 qqx usage
Audio-Encode-LameMP3/t/030-encode.t- ok($buf.elems > 0, "and there are some elements");
Audio-Encode-LameMP3/t/030-encode.t- $out-fh.write($buf);
Audio-Encode-LameMP3/t/030-encode.t- $out-fh.close;
Audio-Encode-LameMP3/t/030-encode.t-
Audio-Encode-LameMP3/t/030-encode.t- if ( "/usr/bin/file".IO.x ) {
Audio-Encode-LameMP3/t/030-encode.t: like qqx/file $out-file }/, rx/MPEG/, "and it's a MP3 file";
--
Audio-Encode-LameMP3/t/030-encode.t- ok($buf.elems > 0, "and there are some elements");
Audio-Encode-LameMP3/t/030-encode.t- $out-fh.write($buf);
Audio-Encode-LameMP3/t/030-encode.t- $out-fh.close;
Audio-Encode-LameMP3/t/030-encode.t-
Audio-Encode-LameMP3/t/030-encode.t- if ( "/usr/bin/file".IO.x ) {
Audio-Encode-LameMP3/t/030-encode.t: like qqx/file $out-file }/, rx/MPEG/, "and it's a MP3 file";
--
Audio-Encode-LameMP3/t/030-encode.t- ok($buf.elems > 0, "and there are some elements");
Audio-Encode-LameMP3/t/030-encode.t- $out-fh.write($buf);
Audio-Encode-LameMP3/t/030-encode.t- $out-fh.close;
Audio-Encode-LameMP3/t/030-encode.t-
Audio-Encode-LameMP3/t/030-encode.t- if ( "/usr/bin/file".IO.x ) {
Audio-Encode-LameMP3/t/030-encode.t: like qqx/file $out-file }/, rx/MPEG/, "and it's a MP3 file";
--
Audio-Encode-LameMP3/t/030-encode.t- ok($buf.elems > 0, "and there are some elements");
Audio-Encode-LameMP3/t/030-encode.t- $out-fh.write($buf);
Audio-Encode-LameMP3/t/030-encode.t- $out-fh.close;
Audio-Encode-LameMP3/t/030-encode.t-
Audio-Encode-LameMP3/t/030-encode.t- if ( "/usr/bin/file".IO.x ) {
Audio-Encode-LameMP3/t/030-encode.t: like qqx/file $out-file }/, rx/MPEG/, "and it's a MP3 file";
--
Audio-Encode-LameMP3/t/030-encode.t- ok($buf.elems > 0, "and there are some elements");
Audio-Encode-LameMP3/t/030-encode.t- $out-fh.write($buf);
Audio-Encode-LameMP3/t/030-encode.t- $out-fh.close;
Audio-Encode-LameMP3/t/030-encode.t-
Audio-Encode-LameMP3/t/030-encode.t- if ( "/usr/bin/file".IO.x ) {
Audio-Encode-LameMP3/t/030-encode.t: like qqx/file $out-file }/, rx/MPEG/, "and it's a MP3 file";
--
Audio-Encode-LameMP3/t/030-encode.t- ok($buf.elems > 0, "and there are some elements");
Audio-Encode-LameMP3/t/030-encode.t- $out-fh.write($buf);
Audio-Encode-LameMP3/t/030-encode.t- $out-fh.close;
Audio-Encode-LameMP3/t/030-encode.t-
Audio-Encode-LameMP3/t/030-encode.t- if ( "/usr/bin/file".IO.x ) {
Audio-Encode-LameMP3/t/030-encode.t: like qqx/file $out-file }/, rx/MPEG/, "and it's a MP3 file";
--
Audio-Encode-LameMP3/t/030-encode.t- ok($buf.elems > 0, "and there are some elements");
Audio-Encode-LameMP3/t/030-encode.t- $out-fh.write($buf);
Audio-Encode-LameMP3/t/030-encode.t- $out-fh.close;
Audio-Encode-LameMP3/t/030-encode.t-
Audio-Encode-LameMP3/t/030-encode.t- if ( "/usr/bin/file".IO.x ) {
Audio-Encode-LameMP3/t/030-encode.t: like qqx/file $out-file }/, rx/MPEG/, "and it's a MP3 file";
--
Audio-Encode-LameMP3/t/030-encode.t- ok($buf.elems > 0, "and there are some elements");
Audio-Encode-LameMP3/t/030-encode.t- $out-fh.write($buf);
Audio-Encode-LameMP3/t/030-encode.t- $out-fh.close;
Audio-Encode-LameMP3/t/030-encode.t-
Audio-Encode-LameMP3/t/030-encode.t- if ( "/usr/bin/file".IO.x ) {
Audio-Encode-LameMP3/t/030-encode.t: like qqx/file $out-file }/, rx/MPEG/, "and it's a MP3 file";
--
Audio-Encode-LameMP3/t/030-encode.t- ok($buf.elems > 0, "and there are some elements");
Audio-Encode-LameMP3/t/030-encode.t- $out-fh.write($buf);
Audio-Encode-LameMP3/t/030-encode.t- $out-fh.close;
Audio-Encode-LameMP3/t/030-encode.t-
Audio-Encode-LameMP3/t/030-encode.t- if ( "/usr/bin/file".IO.x ) {
Audio-Encode-LameMP3/t/030-encode.t: like qqx/file $out-file }/, rx/MPEG/, "and it's a MP3 file";
--
Audio-Encode-LameMP3/t/030-encode.t- ok($buf.elems > 0, "and there are some elements");
Audio-Encode-LameMP3/t/030-encode.t- $out-fh.write($buf);
Audio-Encode-LameMP3/t/030-encode.t- $out-fh.close;
Audio-Encode-LameMP3/t/030-encode.t-
Audio-Encode-LameMP3/t/030-encode.t- if ( "/usr/bin/file".IO.x ) {
Audio-Encode-LameMP3/t/030-encode.t: like qqx/file $out-file }/, rx/MPEG/, "and it's a MP3 file";
--
Audio-Sndfile/test-utils/gen-test-defs-
Audio-Sndfile/test-utils/gen-test-defs-for $files.list -> $f {
Audio-Sndfile/test-utils/gen-test-defs- my $data = {};
Audio-Sndfile/test-utils/gen-test-defs- my $file = $*SPEC.catfile($basedir,$f.basename);
Audio-Sndfile/test-utils/gen-test-defs- $data<filename> = $file;
Audio-Sndfile/test-utils/gen-test-defs: my $info = qqx{sndfile-info $file};
--
doc/util/missing-methods.p6- return $type-name.^methods(:local);
doc/util/missing-methods.p6-}
doc/util/missing-methods.p6-
doc/util/missing-methods.p6-sub show-undoc-method(Str $qualified-method-name) {
doc/util/missing-methods.p6- my $doc-lookup-command = "PAGER=cat ./bin/p6doc -f \'$qualified-method-name\'";
doc/util/missing-methods.p6: my $doc-output = qqx{$doc-lookup-command};
--
doc/lib/Type/Temporal.pod- hour => 7,
doc/lib/Type/Temporal.pod- minute => 0,
doc/lib/Type/Temporal.pod- timezone => $timezone
doc/lib/Type/Temporal.pod- ).Instant;
doc/lib/Type/Temporal.pod- sleep-till $instant;
doc/lib/Type/Temporal.pod: qqx{mplayer wake-me-up.mp3};
--
doc/lib/Language/5to6-perlop.pod-C<my $a = 42;say qqw/$a b c/;> gives you "42 b c".
doc/lib/Language/5to6-perlop.pod-
doc/lib/Language/5to6-perlop.pod-Shell quoting is available through C<qx>, but you should note that
doc/lib/Language/5to6-perlop.pod-backticks do not do shell quoting as in Perl 5, and Perl variables are
doc/lib/Language/5to6-perlop.pod-I<not> interpolated in C<qx> strings. If you need to interpolate Perl
doc/lib/Language/5to6-perlop.pod:variables in a shell command string, you can use C<qqx> instead.
--
doc/lib/Language/quoting.pod- say $output; # hello!
doc/lib/Language/quoting.pod-
doc/lib/Language/quoting.pod-See also L<shell|/routine/shell>, L<run|/routine/run> and L<Proc::Async> for
doc/lib/Language/quoting.pod-other ways to execute external commands.
doc/lib/Language/quoting.pod-
doc/lib/Language/quoting.pod:=head2 X<Shell quoting with interpolation: qqx|quote,qqx>
doc/lib/Language/quoting.pod-
doc/lib/Language/quoting.pod-If one wishes to use the content of a Perl variable within an external
doc/lib/Language/quoting.pod:command, then the C<qqx> shell quoting construct should be used (this
doc/lib/Language/quoting.pod-corresponds to Perl 5's C<qx>):
doc/lib/Language/quoting.pod-
doc/lib/Language/quoting.pod- my $world = "there";
doc/lib/Language/quoting.pod: say qqx{echo "hello $world"}; # hello there
--
doc/lib/Language/quoting.pod-Again, the output of the external command can be kept in a variable:
doc/lib/Language/quoting.pod-
doc/lib/Language/quoting.pod- my $word = "cool";
doc/lib/Language/quoting.pod- my $option = "-i";
doc/lib/Language/quoting.pod- my $file = "/usr/share/dict/words";
doc/lib/Language/quoting.pod: my $output = qqx{grep $option $word $file};
--
doc/htmlify.p6- my $basename = join '-', %*ENV<USER> // 'u', (^100_000).pick, 'pod_to_pyg.pod';
doc/htmlify.p6- my $tmp_fname = "$*TMPDIR/$basename";
doc/htmlify.p6- spurt $tmp_fname, $node.contents.join;
doc/htmlify.p6- LEAVE try unlink $tmp_fname;
doc/htmlify.p6- my $command = "pygmentize -l perl6 -f html < $tmp_fname";
doc/htmlify.p6: return qqx{$command};
--
farabi6/lib/Farabi6/Editor.pm6- # Prepare Perl 6 source for syntax check
farabi6/lib/Farabi6/Editor.pm6- my ($filename,$filehandle) = tempfile(:!unlink);
farabi6/lib/Farabi6/Editor.pm6- $filehandle.print($source);
farabi6/lib/Farabi6/Editor.pm6-
farabi6/lib/Farabi6/Editor.pm6- # Invoke perl -c $temp_file
farabi6/lib/Farabi6/Editor.pm6: my Str $output = qqx{$*EXECUTABLE -c $filename 2>&1};
--
farabi6/lib/Farabi6/Editor.pm6- # Create a temporary file that holds the POD string
farabi6/lib/Farabi6/Editor.pm6- my ($filename,$filehandle) = tempfile(:!unlink);
farabi6/lib/Farabi6/Editor.pm6- spurt $filehandle, $pod;
farabi6/lib/Farabi6/Editor.pm6-
farabi6/lib/Farabi6/Editor.pm6- # Invoke perl6 -doc to convert POD to HTML
farabi6/lib/Farabi6/Editor.pm6: my $html = qqx/$*EXECUTABLE --doc=HTML $filename/;
--
farabi6/lib/Farabi6/Editor.pm6- $filehandle.print($source);
farabi6/lib/Farabi6/Editor.pm6-
farabi6/lib/Farabi6/Editor.pm6- # Run code using rakudo Perl 6
farabi6/lib/Farabi6/Editor.pm6- my $t0 = now;
farabi6/lib/Farabi6/Editor.pm6-
farabi6/lib/Farabi6/Editor.pm6: my Str $output = qqx{$*EXECUTABLE $args $filename 2>&1};
--
farabi6/lib/Farabi6/Editor.pm6- #TODO validate $command
farabi6/lib/Farabi6/Editor.pm6-
farabi6/lib/Farabi6/Editor.pm6- # Start stopwatch
farabi6/lib/Farabi6/Editor.pm6- my $t0 = now;
farabi6/lib/Farabi6/Editor.pm6-
farabi6/lib/Farabi6/Editor.pm6: my Str $output = qqx{$command};
--
farabi6/lib/Farabi6/Editor.pm6- unless $index-file.path ~~ :f
farabi6/lib/Farabi6/Editor.pm6- {
farabi6/lib/Farabi6/Editor.pm6- say "Building index.data... Please wait";
farabi6/lib/Farabi6/Editor.pm6-
farabi6/lib/Farabi6/Editor.pm6- # run p6doc-index build to build the index.data file
farabi6/lib/Farabi6/Editor.pm6: my Str $dummy = qqx{p6doc-index build};
--
farabi6/lib/Farabi6/Editor.pm6-method run-tests {
farabi6/lib/Farabi6/Editor.pm6-
farabi6/lib/Farabi6/Editor.pm6- # Run code using rakudo Perl 6
farabi6/lib/Farabi6/Editor.pm6- my $t0 = now;
farabi6/lib/Farabi6/Editor.pm6-
farabi6/lib/Farabi6/Editor.pm6: my Str $output = qqx{prove -e perl6 2>&1};
--
farabi6/lib/Farabi6/Util.pm6-=end comment
farabi6/lib/Farabi6/Util.pm6-method http-get(Str $url) {
farabi6/lib/Farabi6/Util.pm6- #TODO investigate whether LWP::Simple is installable and workable again
farabi6/lib/Farabi6/Util.pm6- #TODO investigate whether HTTP::Client after the promised big refactor works or not
farabi6/lib/Farabi6/Util.pm6- die "URL is not defined!" unless $url;
farabi6/lib/Farabi6/Util.pm6: qqx/wget -qO- $url/;
Binary file Grammar-BNF/.git/objects/pack/pack-c82d1b61baf47926d827be98be2072ed8665a248.pack matches
--
gtk-simple/Build.pm- if $need-copy {
gtk-simple/Build.pm- # to avoid a dependency (and because Digest::SHA is too slow), we do a hacked up powershell hash
gtk-simple/Build.pm- # this should work all the way back to powershell v1
gtk-simple/Build.pm- my &ps-hash = -> $path {
gtk-simple/Build.pm- my $fn = 'function get-sha256 { param($file);[system.bitconverter]::tostring([System.Security.Cryptography.sha256]::create().computehash([system.io.file]::openread((resolve-path $file)))) -replace \"-\",\"\" } ';
gtk-simple/Build.pm: my $out = qqx/powershell -noprofile -Command "$fn get-sha256 $path"/;
--
Inline-Python/configure.pl6-#!/usr/bin/env perl6
Inline-Python/configure.pl6-use v6;
Inline-Python/configure.pl6-use LibraryMake;
Inline-Python/configure.pl6-
Inline-Python/configure.pl6-sub get_config_var(Str $name) {
Inline-Python/configure.pl6: return chomp(qqx/python -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('$name'));"/);
--
Inline-Python/Build.pm-use Shell::Command;
Inline-Python/Build.pm-use LibraryMake;
Inline-Python/Build.pm-
Inline-Python/Build.pm-class Build is Panda::Builder {
Inline-Python/Build.pm- sub get_config_var(Str $name) {
Inline-Python/Build.pm: return chomp(qqx/python -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('$name'));"/);
--
P6-LibraryMake/t/01-basic.t-chdir("t");
P6-LibraryMake/t/01-basic.t-shell(%vars<MAKE>);
P6-LibraryMake/t/01-basic.t-ok (("test"~%vars<O>).IO ~~ :f), "Object file created";
P6-LibraryMake/t/01-basic.t-ok (("test"~%vars<EXE>).IO ~~ :f), "Binary was created";
P6-LibraryMake/t/01-basic.t-
P6-LibraryMake/t/01-basic.t:ok qqx/.{$*SPEC.dir-sep}test%vars<EXE>/ ~~ /^Hello ' ' world\!\n$/, "Binary runs!";
--
perl6-facter/lib/Facter/Util/Resolution.pm- my $binary = $code.split(" ").[0];
perl6-facter/lib/Facter/Util/Resolution.pm- if $code ~~ /^\// {
perl6-facter/lib/Facter/Util/Resolution.pm- $path = $binary;
perl6-facter/lib/Facter/Util/Resolution.pm- } else {
perl6-facter/lib/Facter/Util/Resolution.pm- Facter.debug("Trying to find which '$binary'");
perl6-facter/lib/Facter/Util/Resolution.pm: $path = qqx{which '$binary' 2>/dev/null}.chomp;
--
perl6-facter/lib/Facter/Util/Resolution.pm-
perl6-facter/lib/Facter/Util/Resolution.pm- my $out;
perl6-facter/lib/Facter/Util/Resolution.pm-
perl6-facter/lib/Facter/Util/Resolution.pm- Facter.debug("Running command $code");
perl6-facter/lib/Facter/Util/Resolution.pm- try {
perl6-facter/lib/Facter/Util/Resolution.pm: $out = qqx{$code}.chomp;
--
Perl6Mongers-Hannover/lib/PerlMongers/Hannover.pm-
Perl6Mongers-Hannover/lib/PerlMongers/Hannover.pm-sub info is export {
Perl6Mongers-Hannover/lib/PerlMongers/Hannover.pm- my $path = "$*CWD";
Perl6Mongers-Hannover/lib/PerlMongers/Hannover.pm- my $package = $path ~ "/lib/PerlMongers/Hannover.pm";
Perl6Mongers-Hannover/lib/PerlMongers/Hannover.pm- my $cmd = "perl6 --doc $package";
Perl6Mongers-Hannover/lib/PerlMongers/Hannover.pm: qqx{$cmd};
Binary file perl6-web/.git/objects/pack/pack-9c3470fdf72cec6882465c0b1c117e3e5a7fb7c5.idx matches
Binary file perl6-web/.git/objects/pack/pack-9c3470fdf72cec6882465c0b1c117e3e5a7fb7c5.pack matches
--
plosurin/lib/Plosurin.pm- my $command = "pod6xhtml -nb -t div -M Perl6::Pod::Lib -c \'=Include $!file";
plosurin/lib/Plosurin.pm- if ( $!rule) {
plosurin/lib/Plosurin.pm- $command ~= "\($!rule\)";
plosurin/lib/Plosurin.pm- }
plosurin/lib/Plosurin.pm- $command ~= "\'";
plosurin/lib/Plosurin.pm: my $body = qqx% $command %;
Binary file SDL6/share/sample.wav matches
--
Test-Corpus/t_files/rot13-example.t.input/7.txt:tglshicecilitu shwtjpufsgyyznyqyldjobbxkjlqrbldqqx
--
Test-Harness/bin/p6prove- next;
Test-Harness/bin/p6prove- }
Test-Harness/bin/p6prove- next unless $f ~~ /'.t' $/;
Test-Harness/bin/p6prove- my $th = Test::Harness::File.new;
Test-Harness/bin/p6prove- print "$f ... " unless $Q;
Test-Harness/bin/p6prove: my @lines = lines(qqx[$e $f]);
Binary file v5/.git/objects/pack/pack-1511e694f770b1df5bb40e50f7863e38a9a1fcdc.pack matches
--
v5/t/test.pl-sub _done() { done() }
v5/t/test.pl-my $tmpfile;
v5/t/test.pl-sub _fresh_perl($a, $b) { # TODO $b contains compiler switches
v5/t/test.pl- my $filename = "$tmpfile.$*PID";
v5/t/test.pl- $filename.IO.spurt("use v5; $a");
v5/t/test.pl: my $result = qqx[%*ENV<PERL6_EXE> $filename];
Binary file XDG-BaseDirectory/.git/objects/pack/pack-bcc054a17d0279fa2b5910861fb5edafbb639178.pack matches
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment