Input file
1. [Table.txt]
Stutbl
Dbtbl
Nametbl
2. [Column.txt]
Stu1,stu2,stu3
DB1
Name1,name2
Output file
[Output.txt]
[STUTBL]
STU1
STU2
STU3
[DBTBL]
DB1
[NAMETBL]
NAME1
NAME2
Implementation code
1 #!/usr/bin/perl-w2 3 $tableFile="Table.txt";4 $columnFile="Column.txt";5 $outputFile="output.txt";6 7 Open(TB,"< $tableFile");8 Open(COL,"< $columnFile");9 Open(Out,"> $outputFile");Ten One @table= <TB>; A @column= <COL>; - - if(@table!=@column ) the { - Print "error!!"; - } - + for($ix=0;$ix<@table;$ix++) - { + $tableName=@table[$ix]; A Chomp($tableName); at PrintOut"[".$tableName."]\n"; - - #@fields = Split (/:/, "1:2:3:4:5") - @col_names=Split(/,/,@column[$ix]); - - #foreach $col _name (@col_names) in for($ix 2=0;$ix 2<@col_names;$ix 2++) - { to PrintOut@col_names[$ix 2]; + - if($ix 2<@col_names-1) the { * PrintOut"\ n"; $ } Panax Notoginseng } - } the + Close(TB); A Close(COL); the Close(out);
Perl File Operations Applet