正規表現パターンが一致しない理由がわかりません。また、出力$found
は初期化されていないと不平を言いますが、そうしたと思います。これまでの私のコードは次のとおりです。
use strict;
use warnings;
my @strange_list = ('hungry_elephant', 'dancing_dinosaur');
my $regex_patterns = qr/
elephant$
^dancing
/x;
foreach my $item (@strange_list) {
my ($found) = $item =~ m/($regex_patterns)/i;
print "Found: $found\n";
}
これが私が得る出力です:
Use of uninitialized value $found in concatenation (.) or string at C:\scripts\perl\sandbox\regex.pl line 13.
Found:
Use of uninitialized value $found in concatenation (.) or string at C:\scripts\perl\sandbox\regex.pl line 13.
Found:
$found
別の方法で初期化する必要がありますか? また、正規表現として解釈される複数行の文字列を正しく作成していますか?
どうもありがとう。