I have been staring at this topic for 5 hours, I am very upset and need some help.
I am writing a Perl script that pulls jobs from a MySQL table and then predicts various database administration tasks. The current challenge is creating databases. The script successfully creates the database, but when I get to creating the configuration file for PHP developers, it will explode.
I believe this is a problem with reference and dereference variables, but I'm not quite sure what exactly is happening. I think after this function call something happens with the $$ result {'Databasename'}. This is how I get the result:$result = $select->fetchrow_hashref()
Here is my function call and function implementation:
Function call (line 127):
generateConfig($$result{'databaseName'}, $newPassword, "php");
Function Execution:
sub generateConfig {
my($inName) = $_[0];
my($inPass) = $_[1];
my($inExt) = $_[2];
my($goodData) = 1;
my($select) = $dbh->prepare("SELECT id FROM $databasesTableName WHERE name = '$inName'");
my($path) = $documentRoot.$inName."_config.".$inExt;
$select->execute();
if ($select->rows < 1 ) {
$goodData = 0;
}
while ( $result = $select->fetchrow_hashref() )
{
my($insert) = $dbh->do("INSERT INTO $configTableName(databaseId, username, password, path)".
"VALUES('$$result{'id'}', '$inName', '$inPass', '$path')");
}
return 1;
}
Errors:
Use of uninitialized value in concatenation (.) or string at ./dbcreator.pl line 142.
Use of uninitialized value in concatenation (.) or string at ./dbcreator.pl line 154.
Line 142:
$update = $dbh->do("UPDATE ${tablename}
SET ${jobStatus}='${newStatus}'
WHERE id = '$$result{'id'}'");
Line 154:
print "Successfully created $$result{'databaseName'}\n";
, , , , , , !
- , , .
,
p.s. , , . = P