- 论坛徽章:
- 0
|
perl读写文字和数据混杂的文件, 有一文件vFloors,内容如下:
~v varFloor1
<Variance> 39
2.882107e-001 1.011243e+000 6.391264e-001 1.449148e+000 8.005224e-001
我希望把它读到另外一个文件 macros
也
脚本如下,发现只能读文字,数据不能读入,该如何解决?
#!/usr/local/bin/perl -w
use strict;
my ($macros, $vFloors,@labs);
# this script makes an mlf out of a list of file names and
# corresponding prompts - ie in the format
# fileid prompt
# fileid prompt
# " "
# The prompts are automatically converted to upper case.
if (@ARGV != 2) {
print "usage: $0 mlf promptlist\n\n";
exit (0);
}
# read in command line arguments
($macros, $vFloors) = @ARGV;
# open MLF file
open (MACROS,">$macros") || die ("Unable to open mlf $macros file for writing");
print "writing to mlf file $macros\n";
print MACROS ("\~o\n");
print MACROS ("\<VECSIZE\> 39\<MFCC_0_D_A\>\n");
# open vFloors file
open (LAB, "$vFloors") || die ("Unable to open vFloors file $vFloors ");
#peint LAB pack("h8",99);
binmode LAB;
while (@labs = <LAB>) {
printf(MACROS "%s\n",@labs);
}
close (LAB);
close(MACROS);
print "writing to $macros file done\n"; |
|