Your immediate problem is that perl interprets your %{ as a hash slice (see http://docstore.mik.ua/orelly/perl/learn/ch05_05.htm for a small example)

Your larger problem is that you want to use a technique that is a relict from perl4 days and only (if at all) suitable for quick hacks

Instead of using

my %{"platform_$site"}; ${"platform_$site"}{"thingy"}= 5; foreach my $x ( keys %{"platform_$site"}) { ...
use multidimensional hashes
my %platform; $platform{$site}{"thingy"}= 5; foreach my $x ( keys %{$platform{$site}}) { ...

You can use the same technique for your arrays as well, i.e. use a so called HashOfArrays:

push @{$platform{$site}}, 1,2; $platform{$site}[5]= 5; foreach my $x ( @{$platform{$site}}) { ..

PS: I also notice you don't use 'use warnings;' and 'use strict;' at the beginning of your script. It is highly advisable to include those two lines. Avoids many bug finding sessions later.


In reply to Re: syntax for hashes with variable in name by jethro
in thread syntax for hashes with variable in name by equick

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.