2026.14 Trim Flip-flops

Habere’s Corner

Habere-et-Dispertire has shared some new notes on using the raku command:

  • Remove leading and trailing whitespace:

raku -ne "put .trim" {{/path/to/file}}

  • Extract lines between START and STOP markers (inclusive)

raku -ne '.put if "START" ff "STOP"' {{/path/to/file}}

  • Extract lines between START and STOP markers (exclusive)

raku -ne '.put if "START" ^ff^ "STOP"' {{/path/to/file}}

TPRC Submit your Talk

Don’t Miss the Perl and Raku Conference 2026 in Greenville, SC
SAVE THE DATES! Friday through Sunday, June 26-28

Registration is open: https://tprc.us/tprc-2026-gsp

Weekly Challenge

Weekly Challenge #368 is available for your entertainment.

Raku Tips ‘n Tricks

This week, my eye was caught by what looked like a simple question on the IRC (Discord) channels:

my (%a, @b, %c, @d= (1, 2).map({ |({"a" => 1}, [1]) });

Why does this seeming straightforward list assignment with = (see docs) cause an error?

Odd number of elements found where hash initializer expected:
Found 5 (implicit) elements: ...

Let’s tease that apart, say we make the LHS just a single Array @b and then a single Hash %a

my @b = (1, 2).map({ |({"a" => 1}, [1]) }); 
#OUTPUT say @b; #[{a => 1} [1] {a => 1} [1]]

my %a = (1, 2).map({ |({"a" => 1}, [1]) });
#ERROR

The docs say that list assignment is governed by the LHS – an Array will take all the RHS elements. We can surmise that a Hash will take all the RHS elements – even splitting key, values – and translate them into key => value pairs. Thus the error if presented with an odd number in total.

Despite this frustration, Raku has two ways to make this work:

my (%a, @b, %c, @dZ= (1, 2).map({ |({"a" => 1}, [1]) });
#-or-
my (%a, @b, %c, @d:= (1, 2).map({ |({"a" => 1}, [1]) });

say {:%a,:@b,:%c,:@d}
#OUTPUT {a => {a => 1}, b => [1], c => {a => 1}, d => [1]}

You can use binding := instead and since the LHS and the RHS have the same data structure this will work. Or you can combine Z (the zip metaoperator) with = (item assignment), like this:

my (a, b, c) Z= (a, b, c);
#turns that assignment into boring
my a = @x[0]; my b = @x[1]; my c = @x[2]

Your contribution is welcome, please make a gist and share via the #raku channel on IRC or Discord.

Questions About Raku

Comments About Raku

New Doc & Web Pull Requests

New Raku Modules

Updated Raku Modules

Leave a comment