develooper Front page | perl.beginners | Postings from December 2002

RES: Hash Question

Igor Sutton Lopes
December 6, 2002 12:30
RES: Hash Question
Message ID:
You can do something like this:

%url_options_hash = ("times_visited"=>0);
%url_hash         = ("this_url"=>\%url_options_hash);
%usr_hash         = ("igor"=>\%url_hash);

print $usr_hash{"igor"}->{"this_url"}->{"times_visited"}, "\n";
$usr_hash{"igor"}->{"this_url"}->{"times_visited"} = 1;
print $usr_hash{"igor"}->{"this_url"}->{"times_visited"}, "\n";

That worked for me, you use in this case the reference for the 'inner' hashes.


> ----- Mensagem original -----
> De:		Sean Rowe []
> Enviada em:		sexta-feira, 6 de dezembro de 2002 11:30
> Para:		Beginners@perl. org (E-mail)
> Assunto:		Hash Question
> I need to keep track of a user, all the web pages a user has visited, and
> the number of times the user visited each page.  I get my information from a
> log file.  Here's how I would like to say it programmatically:
> 	$Hash{"$User"}{"$Page"}{"$NumTimesVisited"} = $ANumber;
> Is this possible?  If so, how would I traverse this, as I will not know
> before hand the values in the hash; I will need to use something like sort.
> Thank you.
> Sean Rowe
> -- 
> To unsubscribe, e-mail:
> For additional commands, e-mail:
> Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About