I have two mysql commands. I want to create a subroutine with these two mysql commands for the rest of my data that I have to search through. I have a lot of entries. Is there a way to create a subroutine such that in place of the actual numbers and characters I put in my two mysql commands, I put in variables that I can replace so I can then copy and paste the actual values of those variables and the commands are executed for the remaining entries?
For example, I have a command that says
$sth = $dbh->prepare ("select name from table1 where number > 5");
$sth->execute();
@row;
while (@row = $sth->fetchrow_array) {
print "$row[0]\tquestion1\n";
In place of the "5" listed in the select command and "question1" listed in the print command, I want to put something in place of it like "variables" so that I can create a subroutine with these commands in it, but you execute and can run the subroutine over and over by plugging in different values for those variables.
something like this: $dbh = DBI->connect($dsn, $user, $password); not sure how to go about doing this for mysql perl.
How do you make subroutine with mysql commands with variables that can be replaced with with actual values of entries that still need to be sorted through?
0 answers
No answers yet.
Log in to answer this question.
your question is not related to bioinformatics. It will be soon closed.
this is just an example. i'm using msql and perl to specifically look at genes and chromosomes. will it still be taken down?