专注各种脚本编程
Baidu
加入收藏夹
本站内容有下面分类知识,欢迎您的到来^_^
shell相关:指令篇 基础篇 脚本欣赏 编程实例 shell问问 shell视频教程 技巧篇 水平测试 E文资料 vi编辑器 高级Bash脚本编程指南
其他:mysql perl c语言 oracle
当前位置:| 主页>perl>

perl读写股票文件程序

百度收藏 QQ搜藏

原文:http://myblog.acrehr.com/?p=116
今天google和baidu了一整天,终于把"读写股票文件"搞了出来.
原理:读写二进制文件(都是用unpack的函数), 我们以后就可以用它读股票文件,读数据模拟股票操作, 股票文件是大智慧股票软件下的日线格式,
测试系统环境:windows2000和FreeBSD 6.2下通过 .

perl例子的代码
———————————————————
$time1 = time();
open(MYFILE,”500001.day”) or die (”cannot open input file file1\n”);

#binmode(MYFILE);
my $buff;
#my $i=1;
while(read(MYFILE, $buff, 40))
{
# $. ,$_ 为内置变量
# $. 为行号
# $_ 行的内容,以回车结尾
# chomp 去除回车
#chomp;
#($a1, $a2, $a3, $a4, $a5, $a6, $a7) = unpack(”H8 H8 H8 H8 H8 H8 H8″, $buff);
($a1, $a2, $a3, $a4, $a5, $a6, $a7) = unpack(”i i i i i i i”, $buff);
print “=>”.$a1.”\n”;
print “=>”.$a2.”\n”;
print “=>”.$a3.”\n”;
print “=>”.$a4.”\n”;
print “=>”.$a5.”\n”;
print “=>”.$a6.”\n”;
print “=>”.$a7.”\n”;
print “***********************\n”;
#if($i==5){ last;}
#$i++;
}

close(MYFILE);
$time2 = time();
print $time2 - $time1;

另外:下载股票文件: 500001.day

上一篇:perl遍历文件夹的方法-使用队列或栈遍历 下一篇:perl进程启动函数eval/system/fork

power by soyo123 2007-2008