Chinaunix

标题: perl cgi运行时读入一个文件,是每次都要重新读取么? [打印本页]

作者: xiufan    时间: 2010-04-03 20:38
标题: perl cgi运行时读入一个文件,是每次都要重新读取么?
cgi里面有个读取大文件的操作,不知有什么好办法,避免多次读取,不想用数据库
作者: guap514    时间: 2010-04-03 21:56
把那几行代码删掉
然后假装自己已经读取了
作者: engrol    时间: 2010-04-03 22:46
fastcgi 可以保留文件指针。

普通的CGI程序没有办法。
作者: xiufan    时间: 2010-04-04 15:04
我用全局变量的形式,可以么
our $data=get_data()
在别的页面里
$data=get_data() unless $data

看书上有这么一种形式,不知道怎么样
作者: ulmer    时间: 2010-04-04 20:54
回复 4# xiufan

Using session method.
from very beginning, read required data from the big file once and store those data into the session.
the rest chained cgi-bin process should access the session file.




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2