Marc (>): > 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?
It's valid syntax. The error you're getting is not a syntax error; it's a run-time error complaining about assigning to something that isn't a container. What you're assigning to is 'GATGGAACTTGACTACGTAAATT', a Str object. That's a bit like trying to assign to the number 5. It should produce an error, and it does. You need to put it into a variable, or an array element, or a hash value -- in short, a "container" -- for it to work. I think part of what felt confusing about this is that you did things in a 'for' loop, so the assignment directly to a Str isn't that obvious. By the way, that 'for' loop over a single element is usually spelled 'given' in Perl 6. I would write your code like this: use v6; use Test; { $_ = 'GATGGAACTTGACTACGTAAATT'; s:g/T/U/; is $_, 'GAUGGAACUUGACUACGUAAAUU', 'RNA'; } // Carl