You're putting your starting string in a variable, $x, but aren't telling the s/// operator specifically what to operate on, so it defaults to $_, which is still at its default value.
On 14/08/18 13:08, ToddAndMargo wrote: > Hi All, > > The Perl 5 guys have it pounded into my head that I > always had to check my substitutions to see if they > worked if not working would crash the program. > > So in Perl 6 I have: > > $ p6 'my $x="abc"; if s/b/z/ {say "sub worked"}else{say "sub failed"}; > say "$x";' > > Use of uninitialized value of type Any in string context. > Methods .^name, .perl, .gist, or .say can be used to stringify it to > something meaningful. > in block <unit> at -e line 1 > sub failed > abc > > > What am I doing wrong? > > Many thanks, > -T