Your request isn't really a quest related question. It is more of a general perl or scripting question. I am sure it can be done easy enough how you are wanting to do it.
You could probably just save yourself some time and use notepad++ to edit your item name list into queries for the item id SELECT. Then, do the same to make the results into queries to insert into the loot tables. You can hold ALT then click and drag up or down to select a column to type in for all rows selected. This means you can select the row in front of your column of item names, and type:
Code:
SELECT * FROM items WHERE `name`="
Then put your cursor at the left of the first line and click Macro->Start Recording. Then hit the END key on your keyboard. Then type the following:
Then hit the DOWN arrow on your keyboard. Then click Macro->Stop Recording. Then Macro->Run a Macro Multiple Times....
Next, select the radio button for "Run until the end of file" and click Run. That should make all lines look like a query. Sometimes you might get a weird character when you run macros, but you can just do a find/replace on that character to remove it if needed.
At that point, you can just run your queries from that list and do the same again with the query results. Once you get used to using notepad++, stuff like that gets really quick and easy to do.
Otherwise, if you are set on getting the script working, here is an example plugin I use on my server to query the DB. Should be able to use it to figure out what you are wanting:
Code:
# Usage: plugin::SetCharVarByName(CharName, VarName, VarValue);
sub SetCharVarByName {
my $CharName = $_[0];
my $VarName = $_[1];
my $VarValue = $_[2];
use DBI;
use DBD::mysql;
$tablename = "charvars";
# Set Database Connection
my $connect = DBConnect();
if (plugin::GetCharVarByName($CharName, $VarName))
{
# Create the Query
$query = "UPDATE $tablename SET value = '$VarValue' WHERE name = '$CharName' AND variable = '$VarName'";
}
else
{
# Create the Query
$query = "INSERT INTO $tablename (name, variable, value) VALUES('$CharName', '$VarName', '$VarValue')";
}
# Prepare and Execute the Query
$query_handle = $connect->prepare($query);
$query_handle->execute();
$connect->disconnect();
return 1;
}
sub DBConnect {
# Configuration Settings
my $database = "dbname";
my $host = "192.168.1.100";
my $port = "3306";
# Set Connect String
my $dsn = "dbi:mysql:$database:$host:$port";
my $user = "dbusername";
my $pw = "password";
# Set Database Connection
my $connect = DBI->connect($dsn, $user, $pw);
return $connect;
}