Perl 6 oneliner to sum up all numbers in a text file
The warning comes from the fact that the third and fourth capture groups are inside an optional part of the regex.  Therefore, $f[4] might not be defined.

Rather than concatenating the parts of a decomposed number, I suggest taking all of $f[0] and replacing any comma with a period.

my $sum = 0;

my regex float {
                 &lt;[+-]&gt;?          # opt. sign
                 \d+              # whole part
                 [ &lt;[.,]&gt; \d+ ]?  # opt. fractional part
                                      #comma is vaild separator
               }

for slurp.match( / \* &lt;float&gt; /, :g ) {
    $sum += +$_&lt;float&gt;.subst( /','/ , '.' , :g );
}

say $sum;