in reply to Re^3: Interpolation in a hash key
in thread Interpolation in a hash key
Ok. Let's get back to basics then :)
When you look things up in a hash, you use a string as the index. So your first example is the same as:
$index = 'connection1_size1'; $$hashRecordPtr{$index};
Do you follow that? The hash index is just any string value.
But what we've done there is to now use a variable as the hash index. Which means that we can now be a bit cleverer.
$index = "connection1_size$count"; $$hashRecordPtr{$index};
So now we have a double-quoted string, and we've used the value of the variable $count within the string.
So that effectively does what you want, but we can cut out the unnecessary $index variable and use the double-quoted string directly as the hash index.
$$hashRecordPtr{"connection1_size$count"};
Is that any clearer?
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Interpolation in a hash key
by ptum (Priest) on Jun 13, 2006 at 16:18 UTC |