What are the Perl equivalents of return and continue keywords in C?

Viewed 22437

I am getting this error when I use this code

sub search {
    my ($a, @a_list) = @_;
    foreach (@a_list) {
        if($_ == $a) return TRUE;
        # continue;
    }
    return FALSE;
}

syntax error at code.pl line 26, near ") return"

  • What is the right way to return TRUE?
  • Also, what is the right way to continue?

I know I should be thinking more in Perl terms than trying to convert C code to Perl this way.

3 Answers
Related