Linux: Raku script to open files from terminal and ask for deletion Raku script to open files from terminal with xdg-open and, with del option, asks for deletion. Happy to receive Raku syntax improvements. Thanks!
use v6;

#| Linux: Opens file 'pattern.ext' with xdg-open and, with del option, asks for deletion 
sub MAIN( $pattern is copy, Str $ext, Str $del? where ( $del ∈ &lt; del nodel &gt; ) = &quot;nodel&quot; ) {

    $pattern = &quot;&quot; if $pattern eq &quot;all&quot;;
    my @files = '.'.IO.dir(test =&gt; /.*$pattern.*\.$ext/);

    for @files -&gt; $file {
        my @args = 'xdg-open', $file.basename;
        my $command = run @args;
        $command.exitcode == 0 or die &quot;system @args failed: $!&quot;;
        if $del eq 'del' {
          my $delete = prompt(&quot;\n \n Delete file $file (s/n) &quot;);
          next if $delete ne &quot;s&quot;;
          say &quot;mv $file /tmp/$file&quot;;
          $file.IO.move(&quot;/tmp/$file&quot;);
        }
        my $exit = prompt(&quot;\n Press 'q' to end, return to continue &quot;);
        last if $exit eq q{q};
    }

    @files = '.'.IO.dir(test =&gt; /.*$pattern.*$ext$/);
    say &quot;-&quot; x 60;
    for @files -&gt; $file { $file.Str.say }
    say &quot;-&quot; x 60;
}
If I just run your program without any arguments, this is what I get:
Usage:
  foo.raku &lt;pattern&gt; &lt;ext&gt; [&lt;del&gt;] -- Linux: Opens file 'pattern.ext' with xdg-open and, with del option, asks for deletion

That's not super helfpul, so let's tackle that first.
#| Linux: Opens file 'pattern.ext' with xdg-open and, with del option, asks for deletion 
sub MAIN(
    $pattern is copy, #= The pattern to match against (use 'all' to match everything)
    Str $ext, #= The extension for the file
    Str $del? where ( $del ∈ &lt; del nodel &gt; ) #= Options for opening ('del' or 'nodel', defaults to 'nodel')
        = &quot;nodel&quot; 
) {
   ...
}

This produces much nicer output:
Usage:
  foo.raku &lt;pattern&gt; &lt;ext&gt; [&lt;del&gt;] -- Linux: Opens file 'pattern.ext' with xdg-open and, with del option, asks for deletion
  
    &lt;pattern&gt;    The pattern to match against (use 'all' to match everything)
    &lt;ext&gt;        The extension for the file
    [&lt;del&gt;]      Options for opening ('del' or 'nodel', defaults to 'nodel')

One thing you'll note is that the #= syntax doesn't play nicely with default values, so while I normally prefer using #= for parameters, the #| might be better when you have defaults.  I personally like to let it breathe a bit more when doing this, but YMMV.
#| Linux: Opens file 'pattern.ext' with xdg-open and, with del option, asks for deletion 
sub MAIN(

    #| The pattern to match against (use 'all' to match everything)
    $pattern,

    #| The extension for the file
    Str $ext,

    #| Options for opening ('del' or 'nodel', defaults to 'nodel')
    Str $del? where {$del &lt;del nodel&gt;} = &quot;nodel&quot;
) {
    ...
}

You'll notice I adjust the $del where clause a bit.  Where clauses expect a block, and using parentheses like you did along with the default value can cause problems IME where the equals sign gets gobbled into the block implied block, so explicit blocks are safest.  Because you've set a default value, you don't need to mark it as explicitly optional.
Now let's look at your main code.  First we have the line
my @files = '.'.IO.dir(test =&gt; /.*$pattern.*\.$ext/);

First, instead of '.'.IO, you can use $*CWD, which identifies the purpose a bit better.  Your regex pattern is a bit off also.  Let's comment it and you'll see what's going on:
    my @files = $*CWD.dir:
        test =&gt; /
            .*        # match any characters
            $pattern  # then the pattern
            .*        # then any characters
            \.        # then literal period 
            $ext      # then the extension
        /);

Regexen declared with / / aren't anchored to the start or end, so the initial .* isn't necessary.  OTOH, you will want an explicit end so you can do
    my @files = '.'.IO.dir:
        test =&gt; /
            $pattern  # the pattern
            .*        # then any characters
            \.        # then literal period 
            $ext      # then the extension
            $         # and end the filename
        /);

It might add a few lines to your code, but commenting regex is a very good idea and can help you catch bugs sometimes.
Now in your main logic block
    for @files -&gt; $file {
        my @args = 'xdg-open', $file.basename;
        my $command = run @args;
        $command.exitcode == 0 or die &quot;system @args failed: $!&quot;;
        if $del eq 'del' {
          my $delete = prompt(&quot;\n \n Delete file $file (s/n) &quot;);
          next if $delete ne &quot;s&quot;;
          say &quot;mv $file /tmp/$file&quot;;
          $file.IO.move(&quot;/tmp/$file&quot;);
        }
        my $exit = prompt(&quot;\n Press 'q' to end, return to continue &quot;);
        last if $exit eq q{q};
    }

Separating out your arguments for run into a separate variable is nice, although obviously not strictly necessary.  Because the result of run is truthy based on its success, and we don't use the exit code anywhere else, we can just put the run inside the unless clause.  If that's compacting too much into too small of a space for you, or if you'll need to use the exit code for later expansions of the script, you could use my $command = run @args; fail '...' unless $command.  (ht Brad in comments).
One thing to consider is if you really want to die.  I don't know the xdg-open command personally, so not sure its mechanics.  If you do need to die (terminates the entire script), then by all means do so.  But since each file is being handled separately, perhaps you'd prefer to warn the user and continue with the others.  In that case, you could use a fail, optionally with a CATCH handler to provide more detailed support:
    for @files -&gt; $file {
        my @args = 'xdg-open', $file.basename;

        fail &quot;system @args failed: $!&quot; 
            unless run @args;

        if $del eq 'del' {
            my $delete = prompt(&quot;\n \n Delete file $file (s/n) &quot;);
            next if $delete ne &quot;s&quot;;
            say &quot;mv $file /tmp/$file&quot;;
            $file.IO.move(&quot;/tmp/$file&quot;);
        }

        my $exit = prompt(&quot;\n Press 'q' to end, return to continue &quot;);
        last if $exit eq 'q';

        CATCH {
           .message.say;
           next if prompt &quot;Would you like to continue processing other files?&quot; eq &quot;y&quot;;
           exit 0;
        }
    }


You'll notice I also gave it a little bit of extra space.  Think of it like separating paragraphs in your code.  I would recommend against using q{q} to match q, just use 'q'.  The special quote structures have their place, but this doesn't feel like one of them.
For the final bit of code, the same thing I mentioned about the regex will apply.  For the output:
    say &quot;-&quot; x 60;
    for @files -&gt; $file { $file.Str.say }
    say &quot;-&quot; x 60;

Works well, but the middle line can be greatly simplified to .Str.say for @files.