- 论坛徽章:
- 0
|
贴代码, 先行谢过~~~
我如果每次增加一个输入文件,就需要加一个while, hash,希望大神帮忙支支招, 看能不能简化下代码:
my($first, $second, $third, $forth, $outfile)=@ARGV;
open FIR, $first or die $!;
open SEC, $second or die $!;
open THD, $third or die $!;
open FORTH, $forth or die $!;
open OUT, ">$outfile" or die $!;
my %fir_hash;
my %sec_hash;
my %thr_hash;
($path=$outfile)=~s/(.+?)\.combine\.scp/$1/;
while(my $line=<FIR>)
{
chomp($line);
$line=~/(.+)\\(.+?).mfcc$/;
$fir_hash{$2}=$line;
}
while(my $line=<SEC>)
{
chomp($line);
$line=~/(.+)\\(.+?).mfcc$/;
$sec_hash{$2}=$line;
}
while(my $line=<THD>)
{
chomp($line);
$line=~/(.+)\\(.+?).mfcc$/;
$thr_hash{$2}=$line;
}
while(my $line=<FORTH>)
{
chomp($line);
$line=~/(.+)\\(.+?).mfcc$/;
print OUT "$fir_hash{$2} $sec_hash{$2} $thr_hash{$2} $line $path\\$2.mfcc\n";
}
close FIR;
close SEC;
close THD;
close FORTH;
close OUT; |
|