So, building off a question about string matching (this thread), I am working on implementing that info in solution 3 into a working solution to the problem I am working on.
However, I am getting errors, specifically about this line of the below function:
next if @$args->{search_in} !~ /@$cur[1]/;
syntax error at ./db_index.pl line 16, near "next "
My question as a perl newbie is what am I doing wrong here?
sub search_for_key
{
my ($args) = @_;
foreach $row(@{$args->{search_ary}}){
print "@$row[0] : @$row[1]\n";
}
my $thiskey = NULL;
foreach $cur (@{$args->{search_ary}}){
print "\n" . @$cur[1] . "\n"
next if @$args->{search_in} !~ /@$cur[1]/;
$thiskey = @$cur[0];
last;
}
return $thiskey;
}
You left off the semicolon at the end of the previous line. That’s what caused the syntax error, anyway. I think you’re also misusing
$args, but it’s hard to be sure about that without knowing how you’re calling this function.