voxforge.org
VoxForge Dev

root/Trunk/Scripts/AcousticModel_scripts/HTK/AMCreate_scripts/perlsort.pl

Revision 2270, 1.6 kB (checked in by kmaclean, 10 months ago)

Flac audio processing updates & GPL v3 updates

Line 
1 #! /usr/bin/perl
2 ####################################################################
3 ###
4 ### script name : perlsort.pl
5 ### version: 0.1
6 ### created by: Ken MacLean
7 ### mail: contact@voxforge.org
8 ### Date: 2006.2.24
9 ### Command: perl ./perlsort.pl [infile-prompts] [outfile-wlist]
10 ###   
11 ### Copyright (C) 2006 Ken MacLean
12 ###
13 ### This program is free software; you can redistribute it and/or
14 ### modify it under the terms of the GNU General Public License
15 ### as published by the Free Software Foundation; either version 3
16 ### of the License, or (at your option) any later version.
17 ###
18 ### This program is distributed in the hope that it will be useful,
19 ### but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 ### GNU General Public License for more details.
22 ###                                                             
23 ####################################################################
24
25 if ($#ARGV != 1) {
26  print "usage: inputfilename outputfilename\n";
27  exit;
28 }
29 $inputfilename = $ARGV[0];
30 $outputfilename = $ARGV[1];
31 open(MYINPUTFILE, "<$inputfilename") or die ("need input file name"); # open for input
32 open(FD, ">$outputfilename") or die ("need output file name"); # open for output
33 print "sorting:";print $inputfilename; print " to:";print "$outputfilename \n";
34
35 my(@lines) = <MYINPUTFILE>;         # read file into list
36
37 @lines = sort(@lines);              # sort the list
38
39 my($line);
40 foreach $line (@lines)              # loop thru list
41    {
42     print FD "$line"#print in sort order
43    }
44 close(MYINPUTFILE);
45 close(FD);
Note: See TracBrowser for help on using the browser.