in reply to Dynamically Building Variable Names

No, you probably don't want that. You want a real data structure, possibly a hash of hashes of arrays by your description.

my $data = { example => { other => [ ], } }; $data->{example}->{other}->[0] = "wuzzle";

See perldoc perlreftut and perldoc perldsc.

Replies are listed 'Best First'.
Re^2: Dynamically Building Variable Names
by jhourcle (Prior) on Apr 22, 2005 at 17:37 UTC

    Or, just to keep it simple, and more like what was requested originally (as there may be something else that we don't know about, that would have problems if it were a deep structure), you can use a flat hash:

    my %data; $data{'exampleother1'} = 'something'; $data{'exampleother2'} = 'something else'; $data{$var1.$var2.$number} = $value; # or using a hashref my $data; $data->{'exampleother1'} = 'something'; $data->{'exampleother2'} = 'something else'; $data->{$var1.$var2.$number} = $value;

    The deeper structure has advantages if you might have values for ($var1.$var2) that collide. (if those should be two discrete values, then use a hash of hashes or some other complex structure. If they should be the same value, then just use a single dimensional hash).