Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub build_script
- {
- my $cols = shift;
- foreach my $col (@$cols)
- {
- print($col . ",\n");
- }
- }
- sub parse_source_file
- {
- my $filename = shift;
- my $table_name = shift;
- my $file;
- my $line;
- my $cols = ();
- if (!open($file, "<", $filename))
- {
- print "file not found\n";
- return;
- }
- while ($line = <$file>)
- {
- $line =~ s/\W+$//;
- my @fields = split(',', $line);
- if ($fields[0] eq $table_name)
- {
- push(@cols, $fields[1]);
- }
- }
- close($file);
- return \@cols;
- }
- sub main
- {
- my $db = uc($ARGV[0]);
- my $table = uc($ARGV[1]);
- my $source = $ARGV[2];
- my $cols = parse_source_file($source, $table);
- build_script($cols);
- }
- main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement