Front page | perl.beginners |
Postings from December 2002
RES: Hash Question
From:
Igor Sutton Lopes
Date:
December 6, 2002 12:30
Subject:
RES: Hash Question
Message ID:
3107CAD51184F745B1C3F45BBF20426F03C8B2@correio.152.248.200.in-addr.arpa
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.
Igor.
> ----- Mensagem original -----
> De: Sean Rowe [SMTP:srowe@ahin.net]
> 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: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
>
-
RES: Hash Question
by Igor Sutton Lopes