On Wednesday, May 24, 2017 12:46 PM, ToddAndMargo wrote:
On Tue, May 23, 2017 at 11:30 PM, ToddAndMargo
<toddandma...@zoho.com> wrote:
Hi All,
I have a test code in progress and I haven't figured out
how to get 'next' to work the way I want.
next if $Line.contains( "TASK type" );
works, but
if $Line.contains( "TASK type" ) {
next;
does not.
What am I missing?
Many thanks,
-T
yes I know I still have some things to fix on it.
<code>
#!/usr/bin/env perl6
use strict;
my @Data = '<TASK type="D">Mission D',
' <NAME type="P">Sol Wheat</NAME>',
' <NAME type="P">Ted Moon</NAME>',
'</TASK>';
# for @Data -> $Line { say "$Line"; }
for @Data -> $Line {
# next if $Line.contains( "TASK type" );
if $Line.contains( "TASK type" ) {
next;
Any data fulfilling the 'if' condition, and thus entering this block
will be 'next'ed. Nothing will pass the 'next'.
But no data not fulfilling the condition will 'see' the code below,
which is not what you intend.
Perhaps you omitted an 'else' clause after the 'next' statement?
my $Name = $Line;
if $Name.contains( "NAME type" ) {
$Name ~~ s/.*?\>//;
$Name ~~ s/\<.*//;
say $Name;
}
}
}
</code>
On 05/23/2017 09:39 PM, Brad Gilbert wrote:
> You do realize that `next` immediately stops the current iteration and
> goes onto the *next* one right?
> That is, there is no point putting any code after it because it will
> never be run.
>
That is what I want. If the current $line has "Task type" in
it, I want to jump to the next line in the array. What am
I missing?