I imagine it's the same problem as this Perl 5 code:

use Test::More;

for ('GATGGAACTTGACTACGTAAATT') {
    s/T/U/g;
    is $_, 'GAUGGAACUUGACUACGUAAAUU', 'RNA';
}


Since $_ is an alias for each element of the list and the only element in
the list is a constant string and you can't modify constants, you get the
error.  Changing your code to:

use v6;
use Test;

my $x = 'GATGGAACTTGACTACGTAAATT';
for $x {
    s:g/T/U/;
    is $_ , 'GAUGGAACUUGACUACGUAAAUU' , 'RNA';
}


Does indeed work.

Though, if what I said is true, the error message is Less Than Awesome.  I
wonder could it be made more helpful?

Hope this helps,

-Scott


On Wed, Oct 24, 2012 at 7:35 AM, Marc Chantreux <kha...@phear.org> wrote:

> hello perl6 people,
>
> On
>
>     This is perl6 version 2012.09.1
>     built on parrot 4.6.0 revision 0
>
> When i try to run
>
>     use v6;
>     use Test;
>     for 'GATGGAACTTGACTACGTAAATT' {
>         s:g/T/U/;
>         is $_
>         , 'GAUGGAACUUGACUACGUAAAUU'
>         , 'RNA';
>     }
>
> I get
>
>     Cannot assign to a non-container
>       in sub infix:<=> at src/gen/CORE.setting:11692
>       in block at /tmp/ZZZ:4
>
> As far as i understand from the doc, s:g/T/U/ is a valid syntax. any idea?
>
> regards
> marc
>

Reply via email to