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

How do I test my substitutions?

Thread Next
From:
ToddAndMargo
Date:
August 14, 2018 11:08
Subject:
How do I test my substitutions?
Message ID:
68be38e1-a276-5a11-4357-1586d9011437@zoho.com
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

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About