.
START ===== D:\ETL\ParseDb.cmd
perl ParseDb.pl DbName.txt
pause
END ================== D:\ETL\ParseDb.cmd
.
START ===== D:\ETL\ParseDb.pl
use strict ;
package Class ;
my $DbInputFile = $ARGV[0] ;
my ( $DbName , $FileExtension ) = split ( '\.' , $DbInputFile ) ;
my $DbOutputFile = "$DbInputFile\.out\.xml" ;
sub main ()
{
open ( FH_DbOutputFile , ">$DbOutputFile " ) or die " Cannot open $DbOutputFile " ;
print FH_DbOutputFile "<DbName>$DbName \n";
my @Tables = {} ;
# READ ALL ROWS TO LIST
open (FH_DbInputFile,$DbInputFile);
my @DbInputFile = <FH_DbInputFile>;
close (FH_DbInputFile);
foreach my $line ( @DbInputFile )
{
#debug print "\$line is $line \n " ;
my ($DbName , $TableName , $ColName) = split ( '\\t' , $line ) ;
print "\$DbName , $DbName , \$TableName , $TableName , \$ColName , $ColName \n" ;
print FH_DbOutputFile "<TableName>$TableName</TableName><ColumnName>$ColName</ColumnName>\n" ;
} #eof foreach my $line ( @DbInputFile )
#call sub 1
#call su
print FH_DbOutputFile "</DbName>\n" ;
close FH_DbOutputFile ;
} #eof sub main
sub func1()
{
}
sub new {
my $self = {};
$self->{'buz'} = 42;
bless $self;
} #eof new const
# action !!!
main();
package SomeOtherPackage ;
END ================== D:\ETL\ParseDb.pl
.
START ===== D:\ETL\DbName.txt.out.xml
<DbName>DbName
<TableName>TableName1</TableName><ColumnName>ColName1
</ColumnName>
<TableName>TableName2</TableName><ColumnName>ColName2
</ColumnName>
<TableName>TableName3</TableName><ColumnName>ColName3
</ColumnName>
<TableName>TableName4</TableName><ColumnName>ColName4
</ColumnName>
<TableName>TableName5</TableName><ColumnName>ColName5
</ColumnName>
<TableName>TableName6</TableName><ColumnName>ColName6
</ColumnName>
<TableName>TableName7</TableName><ColumnName>ColName7
</ColumnName>
<TableName>TableName8</TableName><ColumnName>ColName8
</ColumnName>
<TableName>TableName9</TableName><ColumnName>ColName9
</ColumnName>
<TableName>TableName10</TableName><ColumnName>ColName10</ColumnName>
</DbName>
END ================== D:\ETL\DbName.txt.out.xml
.
START ===== D:\ETL\all.txt
.
START ===== D:\ETL\ParseDb.cmd
perl ParseDb.pl DbName.txt
pause
END ================== D:\ETL\ParseDb.cmd
.
START ===== D:\ETL\ParseDb.pl
use strict ;
package Class ;
my $DbInputFile = $ARGV[0] ;
my ( $DbName , $FileExtension ) = split ( '\.' , $DbInputFile ) ;
my $DbOutputFile = "$DbInputFile\.out\.xml" ;
sub main ()
{
open ( FH_DbOutputFile , ">$DbOutputFile " ) or die " Cannot open $DbOutputFile " ;
print FH_DbOutputFile "<DbName>$DbName \n";
my @Tables = {} ;
# READ ALL ROWS TO LIST
open (FH_DbInputFile,$DbInputFile);
my @DbInputFile = <FH_DbInputFile>;
close (FH_DbInputFile);
foreach my $line ( @DbInputFile )
{
#debug print "\$line is $line \n " ;
my ($DbName , $TableName , $ColName) = split ( '\\t' , $line ) ;
print "\$DbName , $DbName , \$TableName , $TableName , \$ColName , $ColName \n" ;
print FH_DbOutputFile "<TableName>$TableName</TableName><ColumnName>$ColName</ColumnName>\n" ;
} #eof foreach my $line ( @DbInputFile )
#call sub 1
#call su
print FH_DbOutputFile "</DbName>\n" ;
close FH_DbOutputFile ;
} #eof sub main
sub func1()
{
}
sub new {
my $self = {};
$self->{'buz'} = 42;
bless $self;
} #eof new const
# action !!!
main();
package SomeOtherPackage ;
END ================== D:\ETL\ParseDb.pl
.
START ===== D:\ETL\DbName.txt.out.xml
<DbName>DbName
<TableName>TableName1</TableName><ColumnName>ColName1
</ColumnName>
<TableName>TableName2</TableName><ColumnName>ColName2
</ColumnName>
<TableName>TableName3</TableName><ColumnName>ColName3
</ColumnName>
<TableName>TableName4</TableName><ColumnName>ColName4
</ColumnName>
<TableName>TableName5</TableName><ColumnName>ColName5
</ColumnName>
<TableName>TableName6</TableName><ColumnName>ColName6
</ColumnName>
<TableName>TableName7</TableName><ColumnName>ColName7
</ColumnName>
<TableName>TableName8</TableName><ColumnName>ColName8
</ColumnName>
<TableName>TableName9</TableName><ColumnName>ColName9
</ColumnName>
<TableName>TableName10</TableName><ColumnName>ColName10</ColumnName>
</DbName>
END ================== D:\ETL\DbName.txt.out.xml
.
START ===== D:\ETL\all.txt
.
START ===== D:\ETL\ParseDb.cmd
perl ParseDb.pl DbName.txt
pause
END ================== D:\ETL\ParseDb.cmd
.
START ===== D:\ETL\ParseDb.pl
use strict ;
package Class ;
my $DbInputFile = $ARGV[0] ;
my ( $DbName , $FileExtension ) = split ( '\.' , $DbInputFile ) ;
my $DbOutputFile = "$DbInputFi
END ================== D:\ETL\all.txt
.
START ===== D:\ETL\DbName.txt
DbName1 TableName1 ColName1
DbName2 TableName2 ColName2
DbName3 TableName3 ColName3
DbName4 TableName4 ColName4
DbName5 TableName5 ColName5
DbName6 TableName6 ColName6
DbName7 TableName7 ColName7
DbName8 TableName8 ColName8
DbName9 TableName9 ColName9
DbName10 TableName10 ColName10
END ================== D:\ETL\DbName.txt