D
dalyea
I frequently do something like this:
foreach my $key (keys %hash) {
if ($string=~/$key/i) {
do_something;
}
}
Is there an easy and fast and more compact way to compare all
the keys of a hash to a string? Something like:
my @found=grep /$_/ $string, keys %hash;
where @found would contain all the matching keys from the
hash found in $string.
Thanks, I've always wanted to find a better way to do this.
foreach my $key (keys %hash) {
if ($string=~/$key/i) {
do_something;
}
}
Is there an easy and fast and more compact way to compare all
the keys of a hash to a string? Something like:
my @found=grep /$_/ $string, keys %hash;
where @found would contain all the matching keys from the
hash found in $string.
Thanks, I've always wanted to find a better way to do this.