Wow, thanks for all the replies :o)
I am using the sub get_page_content to get variables in a database.
I took the advice of another monk and added a type to the table, so I am passing the "type" only, and it is getting all those variables and putting them in the hash. So It looks like this:
sub get_page_content {
my $type = shift;
my $dbh = DB_File::connect();
$sth = $dbh->prepare (qq{ SELECT `name`,`value` FROM `page_variabl
+es` WHERE `type` = ? });
$sth->execute($type);
my %temp_vars; # WILL THIS KILL THE REST OF THE VALUES?
while(my ($db_name,$db_content) = $sth->fetchrow_array()) {
$temp_vars{$db_name} = $db_content;
}
$sth->finish();
return(%temp_vars);
}
Since I call this with %variables = get_page_content("name"); that would replace the whole hash, right? OR
would it just append the new variables to this list? They will always be unique, as the column `name` has to be unique, or it will error out, when adding new records to the db.
thx,
Richard
BTW, I do have quite a few Perl books, but I have only read two of them("Perl Cookbook" and "Perl and Mysql for the Web"). I'm by no means a Perl guru. ;o)
When I have more time on my hands I'll devour the Others! :o)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.