develooper Front page | perl.perl6.users | Postings from August 2018

How do I test my substitutions?

Thread Next
August 14, 2018 11:08
How do I test my substitutions?
Message ID:
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

What am I doing wrong?

Many thanks,

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About