my (@keys,@values) = ($text =~ /\{IS\:([a-zA-Z0-9_-]+)\}(.*)\{\\IS\:([a-zA-Z0-9_-]+)\}/g);
must match these lines
{IS:cow}moo{\IS:cow}
{IS:cow}moo{\IS:cow}
{IS:dog}bark{\IS:dog}
{IS:dog}meow{\IS:dog} #probably not a dog
which works fine, except that all the values of $ 1, $ 2 and $ 3 are reset to @keys .. so I'm trying to figure out how to get these guys to get a good hash from $ 1 => $ 2 pairs ..
For the full context, what I really need , as a rule, to have a regular expression expression, returns a data structure that looks like (and adds a counter for the number of times the key was found)
{
cow_1 => moo,
cow_2 => moo,
dog_1 => bark,
dog_2 => meow,
}
Is there a way to use the map {} function to accomplish this with Regex? Something like this maybe?
my %datahash = map { ( $1 eq $3 ) ? { $1 => $2 } : undef } @{ regex...};
$1 $3, , ( ), $1 $2 ;
= > ,
{IS:cow}moo{\IS:cow}
{IS:cow}moo{\IS:cow}
{cow_1}
{cow_2}
$cachedData {cow} , cow_ * % datahash...