实在是看不太懂你的需求,想判断一个字符是否同时在哈希的键和对应键的值里面。
如果是的话,个人觉得类似的代码是:
#!perl
use strict;
use warnings;
my %hash = (
# xxxx
);
my $file_name = 'xxxx';
open my $fh, '<', $file_name;
while (my $line = <$fh>) {
# body...
chomp $line;
# ... do something with line
for my $key (keys %hash) {
# get hash value
my $value = $hash{$line};
# data exist in hash key and value
if ( index($key, $line) != -1 and index($key, $value) != -1) {
print "[$line] exist in hash key:[$key] and its value:[$value]$/";
last;
}
}
}
close $fh;
__END__