in reply to If statement in Foreach loop
Look at this line:
You are setting companies to an array with one element, the string "FOO, BAR". You want to set it to two elements in one of the following ways:@companies = ("FOO,BAR");
better yet, you could set your regular expression to match either one and ditch the for loop:@companies = ("FOO", "BAR"); # or @companies = qw(FOO BAR);
# Use quotemeta if companies are not really # foo and bar and contain metacharacters. my $companies = join("|", map(quotemeta, qw(FOO BAR))); print "$1\n" if $content =~ /($companies)/;
|
|---|