# New Ticket Created by "Carl Mäsak" # Please include the string: [perl #122907] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org/Ticket/Display.html?id=122907 >
<TuxCM> m: my@x=("1ab");for @x { s{^(\d+)} = sprintf "%3d:", $1; }; @x.say <camelia> rakudo-moar 16232f: OUTPUT«No such method 'item' for invocant of type 'NQPMu' [...] <gtodd1> so you want to format the digit in the list? <[TuxCM]> gtodd1, yes <gtodd1> m: my @x=("1ab");for @x { s{^(\d+)} = sprintf "%3d :", "$1"; }; @x.say <camelia> rakudo-moar ae11b5: OUTPUT« 0 :ab» <gtodd> TuxCM: hmm so the ^(\d+) bit doesn't work ... with the RHS the as expected? <gtodd> m: my @x=("1ab");for @x { s{^(\d+)} = sprintf "%3d :", $1; }; @x.say <camelia> rakudo-moar ae11b5: OUTPUT«No such method 'item' for invocant of type 'NQPMu' [...] <[TuxCM]> gtodd, why does the $1 have to be quoted??? <[TuxCM]> m: my @x=("1ab");for @x { s{^(\d+)} = sprintf "%3d :", "$1"; }; @x.say <camelia> rakudo-moar 3af250: OUTPUT« 0 :ab» <[TuxCM]> m: my @x=("1ab");for @x { s{^(\d+)} = sprintf "%3d :", $1; }; @x.say <camelia> rakudo-moar 3af250: OUTPUT«No such method 'item' for invocant of type 'NQPMu' [...] <[TuxCM]> THAT is what I was wondering about <masak> m: for my @x = "1ab" { s{^(\d+)} = sprintf "%3d :", Nil } <camelia> rakudo-moar 3af250: OUTPUT«No such method 'item' for invocant of type 'NQPMu' [...] <masak> m: $_ = "1ab"; s{^(\d+)} = sprintf "%3d :", "$1"; .say <camelia> rakudo-moar 3af250: OUTPUT«use of uninitialized value of type Any in string context [...] 0 :ab» <masak> m: $_ = "1ab"; s{^(\d+)} = sprintf "%3d :", $1; .say <camelia> rakudo-moar 3af250: OUTPUT«No such method 'Int' for invocant of type 'Any'» <masak> oh! <masak> $1 ! <masak> m: $_ = "1ab"; s{^(\d+)} = sprintf "%3d :", $0; .say <camelia> rakudo-moar 3af250: OUTPUT« 1 :ab» <masak> :) <masak> I think the real bug is that sprintf reacts badly to a Nil. <masak> m: sprintf "%d", Nil <camelia> rakudo-moar 3af250: OUTPUT«No such method 'item' for invocant of type 'NQPMu' [...] <masak> that's LTA. * masak submits that <masak> m: sprintf "%s", Nil <camelia> rakudo-moar 3af250: OUTPUT«Too many directives: found 1, but no arguments after the format string» <masak> oh... <masak> right, so the problem isn't the Nil as such. <masak> but rather that there's nothing to populate the %d with. <masak> m: sprintf "%d" <camelia> rakudo-moar 3af250: OUTPUT«No such method 'item' for invocant of type 'NQPMu' [...] <masak> should give the same error as <masak> m: sprintf "%s" <camelia> rakudo-moar 3af250: OUTPUT«Too many directives: found 1, but no arguments after the format string»