F
fatted
I have this piece of code ($db_keywords is an array ref of array
references):
if(map($_->[0] =~ /\b$keyword\b/i,@$db_keywords))
{
print "Matched $keyword\n";
}
Which worked fine and dandy, but I now want to know what the value of
$_->[1] is at a match. Now I achieved this as follows:
foreach my $db_k (@$db_keywords)
{
if($db_k->[0] =~ /\b$keyword\b/i)
{
print "$keyword $db_k->[0] $db_k->[1]\n";
}
}
What I'd like to know though:
Is there a way of achieving this (accessing the 2 values of the array
reference at a matching point in $db_keywords) using the if-map style
syntax I was originally using.
references):
if(map($_->[0] =~ /\b$keyword\b/i,@$db_keywords))
{
print "Matched $keyword\n";
}
Which worked fine and dandy, but I now want to know what the value of
$_->[1] is at a match. Now I achieved this as follows:
foreach my $db_k (@$db_keywords)
{
if($db_k->[0] =~ /\b$keyword\b/i)
{
print "$keyword $db_k->[0] $db_k->[1]\n";
}
}
What I'd like to know though:
Is there a way of achieving this (accessing the 2 values of the array
reference at a matching point in $db_keywords) using the if-map style
syntax I was originally using.