#!usr/bin/perl-w
use strict;
my $file_name;#文件名
my $num_1;
my $num_2;
my $num_3;
my $num_4;
my @result=qw//;
my $sum = 0;
my $print_line;#写文件名以及数据处理结果
my $dir_tree = "file_data";#文件夹名
my $file;
my $c_flg1;
my $c_flg2;
my $fi_line;
opendir DR,"$dir_tree" or die "can't open $dir_tree: $!";#打开文件夹
# my @file = readdir DR;
my @file = readdir(DR);#读取文件名到列表中
print "@file";
open (out_file,">","out_file.txt");#打开输出结果文件
foreach $file ( @file ){
$c_flg1 = 0;
$c_flg2 = 0;
print "$file\n";
if( $file =~/\.\.?$/ ){#跳过.和..
print "next";
next;
}
open (in_file,"<","$dir_tree\\$file")||die "Can't open $dir_tree\\$file: $!";#打开文件,win下用\
# open (out_file,">","out_file.txt");
while( <in_file> ){
if( /^e.*dn:.(-?\d+\.?\d+)\s+(-?\d+\.?\d+)$/g ){#匹配
$num_1 = $1;
print "num_1 $num_1\n";
$num_2 = $2;
$c_flg1 =1;
print "num_2 $num_2\n";
}
if( /^e.*up:.(-?\d+\.?\d+)\s+(-?\d+\.
perl读取文件夹下的文件
最新推荐文章于 2022-05-22 23:50:04 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)