[問題] 請問perl有nested hash嗎?
我的問題是這樣的...對於下面的文件:
219.68.138.37 http://www.top-sites.ws/
80.199.93.248 http://chat.yahoo.com
56.184.122.209 http://g.msn.com/
56.184.122.209 http://g.msn.com/
56.184.122.209 http://members.msn.com/
........等等
我希望使用者選定一個IP,然後程式可以針對其參觀的網址作排行
我現在的寫法是先建一個key/value: IP/website的Hash table
然後這個hash應該長成:
219.68.138.37 http://www.top-sites.ws/
80.199.93.248 http://chat.yahoo.com
56.184.122.209 http://g.msn.com/ http://g.msn.com/ http://members.msn.com/
接下來我用values取出這個hash的value作處理,也就是現在只對右手邊的網址做處理
像第三行網址中http://g.msn.com/出現2次,而http://members.msn.com/只出現一次
所以以56.184.122.209這個IP來說,http://g.msn.com/是他比較常去的,所以應顯示
219.68.138.37 http://www.top-sites.ws/
80.199.93.248 http://chat.yahoo.com
56.184.122.209 http://g.msn.com/ http://members.msn.com/
大概是這樣,我希望做出巢狀Hash的樣子,以上例來說就是
key value
( IP website),而其中的website又跟參觀次數count形成一個hash table
請問大家這樣要怎麼做呢,我可能敘述的不好,但還是希望有人能看懂^^"
謝謝:)
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.116.82.173
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 6 篇):