免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1477 | 回复: 5
打印 上一主题 下一主题

[新手问]perl里面经常使用硕大无比的hash吗? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-08-21 23:57 |只看该作者 |倒序浏览
接了一个完成度90%的程序,parse xml数据然后用直观方式表示出来,20多个源文件,大部分文件都硕大的hash作为成员变量,一共竟然定义了超过2万行的hashtable,都是静态的,用来look up,validate等等,看得是眼花缭乱,实在搞得很迷糊,不知道perl里面是不是会经常使用这种硕大的look up table的数据结构呢?

论坛徽章:
0
2 [报告]
发表于 2006-08-22 12:57 |只看该作者
原帖由 woqpalsk 于 2006-8-21 23:57 发表
接了一个完成度90%的程序,parse xml数据然后用直观方式表示出来,20多个源文件,大部分文件都硕大的hash作为成员变量,一共竟然定义了超过2万行的hashtable,都是静态的,用来look up,validate等等,看得是眼花 ...


仿佛

难道不方便吗?

论坛徽章:
0
3 [报告]
发表于 2006-08-22 13:02 |只看该作者
原帖由 aaronvox 于 2006-8-22 12:57 发表


仿佛

难道不方便吗?


只是太庞杂,文档注释又不是很齐全,比较让人难以理清头绪

论坛徽章:
0
4 [报告]
发表于 2006-08-22 17:46 |只看该作者
难道没更好的方法?

论坛徽章:
0
5 [报告]
发表于 2006-08-22 19:20 |只看该作者
原帖由 woqpalsk 于 2006-8-21 23:57 发表
接了一个完成度90%的程序,parse xml数据然后用直观方式表示出来,20多个源文件,大部分文件都硕大的hash作为成员变量,一共竟然定义了超过2万行的hashtable,都是静态的,用来look up,validate等等,看得是眼花 ...


硕大的Hash很耗系统内存,偶处理这种数据都是用DB_File来存储的,可以将hash tie到文件系统,用伯克利DB文件来存储。

论坛徽章:
0
6 [报告]
发表于 2006-08-22 20:12 |只看该作者

回复 1楼 woqpalsk 的帖子

Hallo,

I should say yes!
Because perl using such complex data structure has advantage but alse disadvantage too.
Advantage is that you can very simply process any vars in those data structure.
Disadvantage is that many memery are required if the data structure is greater and greater.
For example,  the module Net::LDAP - Lightweight Directory Access Protocol uses this
data structure mothed to store search result from LDAP records, you will find CPU's and memery occupied huge percenatge. the module for XML, I think, is to use those data
structure too.

Wenn you write own code to use the complex data structure, save the data which you exactly want. even if the data is still too large, the mothed of using DB_File,pm, Storable,pm is alternative too.

Please ref. to perldoc perllol, perldocdsc.

Best,
    ulmer

--------------
Just 4 Fun
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP