Dear perl monks, I have a questions which might be easy, but I am really stuck. I have the following script"
#!/usr/bin/perl use DBI; use Data::Dumper; use strict; use warnings; use CGI; my $fields; my $q= CGI->new(); # Connect to the database my $dbh = DBI->connect('DBI:mysql:mirnas', 'root', 'pass') or die "Couldn't open database: $DBI::errstr; stopped"; my $filename = $ARGV[0]; my $table_name = $ARGV[1]; open(INPUT, $filename); #getting the column names from the text file my $line = <INPUT>; chomp($line); my @fields = split('\t', $line); foreach $fields(@fields){ print "$fields\n"; } $sth = $dbh->prepare("create table $tablename ); $sth->execute;
What I want to do is to create a table where all the columnn names will be the ones stored in fields. I was thinking of using a loop structure where foreach $field it would add a column, but I am not sure if this is thebest way to do that. any suggestions would be really usefull, thank you in advance
In reply to DBI question by gogoglou
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |