- 論壇徽章:
- 0
|
貼代碼, 先行謝過~~~
我如果每次增加一個(gè)輸入文件,就需要加一個(gè)while, hash,希望大神幫忙支支招, 看能不能簡(jiǎn)化下代碼:
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; |
|