Newbie here. I'm not sure if I'm supposed to use an array or not. I was able to run a system command that listed out table names in mysql (command line). For each table name given, I want to print out a statement. So far I can execute the system call, and it spits out the list, but that's it. I can't get it to run in the loop to print out the statement. I also just want the table name. My regex maybe wrong too. I know I'm missing something fairly obvious or not using array correctly. Also, I would like this to output to a file that I can execute. If you can me started with that too. Thanks.
#!/usr/bin/perl -w
use strict;
my $manual = qq(mysql -u root db2 -ss -e "show tables");
my $run = system $manual;
my @list = $run;
while (<@list>) {
chomp;
if (/^[^\W\d_]+$/) { # look for any tablename
print "Create table $_ as select * from $_ limit 10\n";
} else {
print "$_: line noise\n";
}
};
#!/usr/bin/perl -w
use strict;
my $manual = qq(mysql -u root db2 -ss -e "show tables");
my $run = system $manual;
my @list = $run;
while (<@list>) {
chomp;
if (/^[^\W\d_]+$/) { # look for any tablename
print "Create table $_ as select * from $_ limit 10\n";
} else {
print "$_: line noise\n";
}
};