perl6

How to edit the source code in module after installed it using zef?

戏子无情 提交于 2019-12-01 18:36:30
问题 For example, I've installed the Cro module, when I run my simple code: my %headers = {Authorization => OAuth realm="", oauth_consumer_key="xxxxxxxxxxxxxxxx", oauth_nonce="29515362", oauth_signature="KojMlteEAHlYjMcLc6LFiOwRnJ8%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1525913154", oauth_token="xxxx-xxxxxxxxxxxxxxxxxx", oauth_version="1.0", User-Agent => Cro}; my $resp = await Cro::HTTP::Client.get: 'http://api.fanfou.com/statuses/home_timeline.json', headers => [ user-agent =>

How can I run external programs using Perl 6? (e.g. like “system” in Perl 5)

ε祈祈猫儿з 提交于 2019-12-01 18:25:29
I can use system in Perl 5 to run external programs. I like to think of system like a miniature "Linux command line" inside Perl. However, I cannot find documentation for system in Perl 6. What is the equivalent? Christoph In addition to using shell or run , which replace system from Perl 5, you can also use NativeCall to invoke the libc system function. On my Windows box, it looks like this: use NativeCall; sub system(Str --> int32) is native("msvcr110.dll") { * }; system("echo 42"); Perl6 actually has two commands that replace system from Perl 5. In Perl6, shell passes its argument to the

How to edit the source code in module after installed it using zef?

泪湿孤枕 提交于 2019-12-01 18:06:01
For example, I've installed the Cro module, when I run my simple code: my %headers = {Authorization => OAuth realm="", oauth_consumer_key="xxxxxxxxxxxxxxxx", oauth_nonce="29515362", oauth_signature="KojMlteEAHlYjMcLc6LFiOwRnJ8%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1525913154", oauth_token="xxxx-xxxxxxxxxxxxxxxxxx", oauth_version="1.0", User-Agent => Cro}; my $resp = await Cro::HTTP::Client.get: 'http://api.fanfou.com/statuses/home_timeline.json', headers => [ user-agent => 'Cro', content-type => 'application/json;charset=UTF-8', |%headers ]; say $resp.header('content-type')

Is there a way to get the version from META6.json in Perl6 module code?

半城伤御伤魂 提交于 2019-12-01 17:46:40
I want to do something like this: die "Fatal error: application version $MY-APPLICATION-VERSION" Since a Perl6 module cannot assume the relative locations of files it was packaged with (for instance installed modules are all put into a flat directory structure) I can't just do $?FILE.IO.add("../META6.json").slurp . Is there a way to get the version declared in META6.json in a Perl6 app/module that may or may not be installed? As of rakudo v2019.03 modules may access the Distribution object used to load it via $?DISTRIBUTION . This allows the following: unit module My::Module; BEGIN my $VERSION

Filtering elements of an array with elements of another array in Perl 6

最后都变了- 提交于 2019-12-01 17:41:53
问题 I want to filter elements of @array which begin with elements of @search : my @array = "aaaaa" .. "fffff"; my @search = "aaaa" .. "cccc"; .put for @array .grep: /^ @search /; The problem is it takes 19 seconds. So, I 'precompile' the regex for grep , and the whole program looks like this: my @array = "aaaaa" .. "fffff"; my @search = "aaaa" .. "cccc"; my $search = "/@search.join('|')/".EVAL; .put for @array .grep: * ~~ /^ <$search> /; Now it takes 0.444s. The question: is there a built-in Perl

Access POD from another Perl 6 file

妖精的绣舞 提交于 2019-12-01 17:23:44
The Perl 6 POD documentation has a section on accessing the current file's POD document by using $=pod . There is no information on accessing another file's POD document. How can I access another file's POD structure, without altering the current file's $=pod ? You can now do that with Pod::Load . From the README in the examples directory perl6 -e 'use Pod::Load; .perl.say for load("pod-load-clean.pod6")' Please note that the Pod6 file has to be "clean", that is, not use any external module that is not generally available or it might fail. Perhaps someone knows a clean way to do this, in which

Cannot import Perl5 module using Inline::Perl5 into Perl6

北城以北 提交于 2019-12-01 17:04:55
I'm trying to import a Perl5 module I really like https://metacpan.org/pod/Data::Printer using advice from the manual page https://modules.perl6.org/dist/Inline::Perl5:cpan:NINE using a very simple script use Inline::Perl5; my $p5 = Inline::Perl5.new; $p5.use('Data::Printer'); but then I get this error: Unsupported type NativeCall::Types::Pointer<94774650480224> in p5_to_p6 in method p5_to_p6_type at /usr/lib/perl6/site/sources/130449F27E85303EEC9A19017246A5ED249F99E4 (Inline::Perl5) line 298 in method unpack_return_values at /usr/lib/perl6/site/sources/130449F27E85303EEC9A19017246A5ED249F99E4

Perl6: getting array ref for Perl5 Module

爱⌒轻易说出口 提交于 2019-12-01 16:51:17
问题 I'm trying to write an Excel notebook in Perl6, using Excel::Writer::XLSX. I'm using Inline::Perl5 via use Excel::Writer::XLSX:from<Perl5> Specifically, I want to write a row like I did in Perl5: $worksheet -> write_row(0,0, \@line); but this gives error To pass an array, hash or sub to a function in Perl 6, just pass it as is. For other uses of Perl 5's ref operator consider binding with ::= instead. Parenthesize as (...) if you intended a capture of a single variable. so I try advice1:

Macros do not allow definition of lexical variables

ぃ、小莉子 提交于 2019-12-01 16:48:51
This code that uses (experimental) macros: use experimental :macros; macro new-var() { quasi { my $a = 42 } }; new-var; say $a Fails with Variable '$a' is not declared , although the macro passes through without an error. If that's a correct macro declaration, what does it do? If it's not, is there a way to define new variables from within a macro? Jonathan Worthington The answer from moritz is correct about the state of macros, though from what I know of the work being done in 007, I don't think the program as written would be correct even with a working implementation of Perl 6 macros. Perl

How to use :since with CompUnit

ε祈祈猫儿з 提交于 2019-12-01 16:19:41
I am trying to create a cache of POD6 by precompiling them using the CompUnit set of classes. I can create, store and retrieve pod as follows: use v6.c; use nqp; my $precomp-store = CompUnit::PrecompilationStore::File.new(prefix=>'cache'.IO); my $precomp = CompUnit::PrecompilationRepository::Default.new(store=> $precomp-store ); my $key = nqp::sha1('test.pod6'); 'test.pod6'.IO.spurt(q:to/CONTENT/); =begin pod =TITLE More and more Some more text =end pod CONTENT $precomp.precompile('test.pod6'.IO, $key, :force); my $handle = $precomp.load($key, )[0]; my $resurrected = nqp::atkey($handle.unit,'$