[問題] 請問perl有nested hash嗎?

看板Perl作者 (和賀英良)時間19年前 (2004/12/11 11:32), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/6 (看更多)
我的問題是這樣的...對於下面的文件: 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
文章代碼(AID): #11kcfbQ1 (Perl)
討論串 (同標題文章)
文章代碼(AID): #11kcfbQ1 (Perl)