raku

Print embedded Pod as formatted text with termcap escapes

删除回忆录丶 提交于 2019-12-23 10:25:41
问题 I am trying to output embedded Pod as ANSI text to the terminal. In Perl 5 I can use Pod::Text::Termcap: use strict; use warnings; use Pod::Text::Termcap; my $str = do {local $/; <DATA>}; my $parser = Pod::Text::Termcap->new(); $parser->parse_string_document( $str, \*STDERR ); __DATA__ =head1 SYNOPSIS my_test_command I<filename> [OPTIONS] =head1 ARGUMENTS =over 4 =item I<filename> File name to test =back =head1 OPTIONS =over 4 =item B<--help> Prints help =back =head1 DESCRIPTION A sample test

Passing pointer to pointer in Perl 6 NativeCall

荒凉一梦 提交于 2019-12-23 10:14:21
问题 I'm trying to use NativeCall to interact with some C functions. For one case, I need to pass in pointers that get updated by the function, so it wants a pointer to a pointer, 'void **'. I tried it like this: class Foo { has Pointer $.first; has Pointer $.last; sub somefunc(Pointer is rw, Pointer is rw, Str) is native { * } method myfunc(Str $arg) { somefunc($!first, $!last, $arg); } } It doesn't work. The pointers don't get updated by the function. Since a C array is basically a pointer to a

.precomp…repo-id subfolder in working folder of Perl 6

一世执手 提交于 2019-12-23 09:59:43
问题 I usually find hidden subfolders in working directories, which, as I suppose, were produced by the Perl 6 compiler, e.g.: .precomp/0717742595706FA8D59800F9F9F7074236546DE7.1505852292.23535/0B/0BDF8C54D33921FEA066491D8D13C96A7CB144B9.repo-id So, I have two questions: Is it normal? Is it indispensable for the compiler or there is a way to avoid it? 回答1: The .precomp folder houses the precompiled form of Perl 6 modules. The first time you use a module it gets compiled and stored in .precomp so

Using Perl6 to process a large text file, and it's Too Slow.(2014-09)

拥有回忆 提交于 2019-12-23 09:57:29
问题 The code host in https://github.com/yeahnoob/perl6-perf , as follow: use v6; my $file=open "wordpairs.txt", :r; my %dict; my $line; repeat { $line=$file.get; my ($p1,$p2)=$line.split(' '); if ?%dict{$p1} { %dict{$p1} = "{%dict{$p1}} {$p2}".words; } else { %dict{$p1} = $p2; } } while !$file.eof; Running well when the "wordpairs.txt" is small. But when the "wordpairs.txt" file is about 140,000 lines (each line, two words), it is running Very Very Slow. And it cannot Finish itself, even after 20

Changing $*DISTRO values for testing

情到浓时终转凉″ 提交于 2019-12-23 09:57:08
问题 I need to test a feature that includes this line: if $translate-nl && $*DISTRO.is-win I have tried to reassign a value to $*DISTRO, $*DISTRO='Windows 10'; but it says: Cannot modify an immutable Distro (debian (9.stretch))␤ $*DISTRO is a dynamic variable, and it makes sense that it's not modified. That said, is there any other way that code can be tested (other than going to Windows, of course) 回答1: my $*DISTRO = ... Hopefully modifying the original is unnecessary. It's generally unreasonable

Create GitHub actions that use powershell scripts

纵然是瞬间 提交于 2019-12-23 09:47:54
问题 I'd like to create a GitHub action that sets up an environment in Windows, running a few Powershell commands. Despite this can be done easily as a step, there does not seem to be a way to create a complete GitHub action for that. If I use this: name: 'Rakudo Star fix for windows' description: 'Updates zef for RakudoStar' author: 'JJ' runs: using: 'node12' main: 'upgrade.ps1' There does not seem a way to run anything other than a JS script, or even to declare the environment. I understand that

How to disable Perl 6 REPL creating .precomp

不想你离开。 提交于 2019-12-23 09:40:14
问题 Every time I run perl6 to enter the REPL mode, it creates a .precomp directory, which also slows down the appearance of the prompt. If the .precomp directory already exists, the prompt appears almost immediately, otherwise perl6 takes several seconds to create it. Is there a way to disable this feature? 回答1: Check if you have a PERL6LIB environment variable set, and if it contains . . I can produce exactly the behavior you're encountering if I set that. The solution is to clear that from your

Perl6 REPL usage

十年热恋 提交于 2019-12-23 09:03:11
问题 Is it possible to have (Rakudo) Perl6 execute some code before dropping you into the REPL? Like python does with "python -i ". For instance, I want to load up some modules and maybe read a side file and build some data structures from that side file before dropping into the REPL and letting the user do the things they need to do on the data structure, using the REPL as a user interface. This is similar but different than Start REPL with definitions loaded from file though answers to this

Is it safe, to share an array between threads?

会有一股神秘感。 提交于 2019-12-23 09:01:30
问题 Is it safe, to share an array between promises like I did it in the following code? #!/usr/bin/env perl6 use v6; sub my_sub ( $string, $len ) { my ( $s, $l ); if $string.chars > $len { $s = $string.substr( 0, $len ); $l = $len; } else { $s = $string; $l = $s.chars; } return $s, $l; } my @orig = <length substring character subroutine control elements now promise>; my $len = 7; my @copy; my @length; my $cores = 4; my $p = @orig.elems div $cores; my @vb = ( 0..^$cores ).map: { [ $p * $_, $p * (

Unexpected Hash flattening

不问归期 提交于 2019-12-23 08:53:53
问题 I'm looking for explanation why those two data structures are not equal: $ perl6 -e 'use Test; is-deeply [ { a => "b" } ], [ { a => "b" }, ];' not ok 1 - # Failed test at -e line 1 # expected: $[{:a("b")},] # got: $[:a("b")] Trailing comma in Hashes and Arrays is meaningless just like in P5: $ perl6 -e '[ 1 ].elems.say; [ 1, ].elems.say' 1 1 But without it Hash is somehow lost and it gets flattened to array of Pairs: $ perl6 -e '[ { a => "b", c => "d" } ].elems.say;' 2 I suspect some Great