Your data structure doesn't look like you think it does. Values can't be arrays. They have to be references.
Here's some similar code that may help you get going better. I also threw in a little use of Data::Dumper since it can be handy to figure out what what your data structures look like.
use warnings;
use strict;
use Data::Dumper;
my $primary_features = {
foo => [ 'fool', 'food', 'foot', ],
bar => [ 'barricade' ]
};
print Data::Dumper::Dumper( $primary_features );
while (my ($key, $value) = each(%$primary_features)){
print "($key, $value)\n";
}
Also, note a few things:
- I used => instead of ",". They're almost the same, except => puts whatever is to the left of it in quotes, and it's traditionally used to separate the keys and values of things in hash definitions.
- I made a reference to an array with square brackets instead of parentheses. You can make an array with the qw() operator, so qw( fool food fort ) is the same as 'fool', 'food', 'fort' , and may be easier to type.
- When you print out $value, it's going to show something like "ARRAY(0x10080fe18))" that means you're trying to print an array. You can iterate over your array or something like that to print something more useful.
- use warnings and strict. They help you find when you're typing something that doesn't make sense.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.