Ok. I now see the problem.
When you are building your %patterns hash, you are reading the tagged data into an array and then assigning a reference to that array as the value in your hash.while (<PFILE>) { chomp; next unless $_; my @tags = split /; |:/; my $key = shift @tags; $patterns{$key} = \@tags; ## <<< HERE }
(I didn't encounter the problem because I bypassed this piece of code as I don't have your datafile.)
There are two ways around the problem depending on how you use the data later. If you don't need to access the array's elements individually in other parts of the code, you can convert the array to a scalar when you assign it to the hash. That means substituing the following line for the one I flagged in the code above.
$patterns{$key} = "@tags";
That will convert the array to a scalar and the rest of the program should then work.
However, if you need to use the array as an array elsewhere in your program, then you will need to modify the code that builds the second hash.
If this is needed and you have trouble with it, come back with your attempt at the code to do this, and I'll try and help you further.
In reply to Re: Re: Re: Re: Re: Re: Re: Match key and return value in some order
by BrowserUk
in thread Match key and return value in some order
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |