On 8/21/06, Andy Greenwood <[EMAIL PROTECTED]> wrote:
I have a program which I am working on which has several different
packages. One of these packages, FluxDB.pm, creates an array of hashes
called @users. Each element is a hash containing (among other things)
username and uid (primary key from the DB this is generated out of).
To be sure, you mean that each element is a *reference* to a hash.
@FluxDB::users is an array of references; what we call an "array of
hashes" in Perl is really an "array of references to hashes".
in Qmgr.pm
foreach my $user (@FluxDB::users) {
# $user should be a regular hash here, correct?
$user{'foo'} = ();
$user{'bar'} = ();
}
The comment is incorrect; $user should be a reference to a hash. Thus
you can write code like this:
foreach my $user (@FluxDB::users) {
$user->{'foo'} = 42;
$user->{'bar'} = undef;
print "Yabba dabba doo?\n" if $user->{'name'} eq "Fred";
}
Is that what you're looking for? There are several documentation pages
about references that may fill in some gaps for you. Hope this helps!
--Tom Phoenix
Stonehenge Perl Training
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>