in reply to Re: Help with complex data structures
in thread Help with complex data structures

Use a hash of array of hashes, so that we can remember more than one file per user:

# store the values push @{$files{$uid}}, { name => $name, size => $size, age => $age}; # use them foreach my $uid (keys %files) { print "$uid: files are:\n"; foreach my $file (@{$files{$uid}}) { print " $file->{name}\n"; } }

Updated: D'oh. Must remember to braces around the key when dereferencing $file->{name} (rather than $file->name)

--
Tommy
Too stupid to live.
Too stubborn to die.

Replies are listed 'Best First'.
Re: Re: Re: Help with complex data structures
by neilwatson (Priest) on Nov 14, 2002 at 16:33 UTC
    print " $file->name\n"; produces output like this:

    HASH(0x80ed0cc)->name
    HASH(0x80ed0fc)->name
    HASH(0x80ed180)->name
    HASH(0x80ee984)->name
    etc...

    Update: check that. The syntax $file->{name} should be used.

    Update again! Thanks for everyone's input. I have a first draft of the program here if you are interested.

    Neil Watson
    watson-wilson.ca