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

sub name has unexpected interaction with s///

Thread Next
From:
Richard Hogaboom
Date:
October 22, 2018 20:52
Subject:
sub name has unexpected interaction with s///
Message ID:
341e5143-3e4b-202e-97aa-23db3de29ab1@gmail.com
The following code:

use v6;

my $str = 'abc';

sub s {1};
say s;

$str ~~ s:g/ b /x/;
dd $str;
say $/;

outputs:

1
Str $str = "axc"
(「b」)

as expected.

But, just remove the :g global flag and:

===SORRY!=== Error while compiling /home/hogaboom/hogaboom/Perl6/p6ex/./t.p6
Undeclared routine:
     b used at line 10

results.

Is the sub name s() interfering with the s/// somehow, but s:g/// does not?


rahogaboom

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