Skip to content

Instantly share code, notes, and snippets.

@tmtvl
Last active July 28, 2019 19:59
Show Gist options
  • Save tmtvl/015c983a78a7e5f8bbbe9ac20f9b8dca to your computer and use it in GitHub Desktop.
Save tmtvl/015c983a78a7e5f8bbbe9ac20f9b8dca to your computer and use it in GitHub Desktop.
Perl 6 notes

Perl 6 notes

Typing

do-a-thing(Array[Rat].new(0.5, 1.5));

Grepping out Rats

my Rat @rats = @mixed.map: { try { CATCH { next; }; .Rat } };

Naming variables for a map or grep

@array.map(-> $val { ... });
# Or
@array.map({ $^val });

Files starting with a literal . in IO::Path:dir

$dir.IO.dir(test => { !m/^\./ });                       # Exclude files starting with a literal .
$dir.IO.dir(test => { m/^\.[\.?<-[.]>.* || \.\..*]/ }); # List only files starting with a literal . excluding . and ..

Create vim commands to edit message hash files

ack 'MENU_ENUM_LABEL_VALUE_POINTER_ENABLE' . | perl6 -e 'say "vim -o { .key } label_display_mode_messages.txt +{ .value }" for map { $_[0] => $_[2] ~~ m/"MSG_HASH"/ ?? $_[1] !! $_[1] - 1 }, map { .split(":") }, lines();'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment