I am getting errors by my code, which I can see why, I wrote this a few years ago, is there a better way to do it?
sub Get_Page_Vars { my ($temp_vars,$type) = @_; my $sth = $dbh->prepare (qq{ SELECT `name`,`value`,`add_name` FROM + `page_vars` WHERE `type` = ? OR `type2` = ? ORDER BY add_name,id,d}) +; $sth->execute($type,$type); while(my ($db_name,$content,$_add_name) = $sth->fetchrow_array()) +{ defined($content); $content =~ s/(\$[a-zA-Z0-9\{\'\}_]+)/ eval($temp_vars{$1}) /g +e if $temp_vars{$1}; $content =~ s/(\$[a-zA-Z0-9\{\'\}_]+)/ $temp_vars{eval($1)} /g +e if $temp_vars{$1}; $content =~ s/\<templ_var ([a-zA-Z0-9\{\'\}_]+)\>/ eval ($vars +{$1}) /ge if $vars{$1}; $content =~ s/\<templ_var ([a-zA-Z0-9\{\'\}_]+)\>/ $vars{eval( +$1)} /ge if $vars{$1}; $content =~ s/\<templ_var ([a-zA-Z0-9\{\'\}_]+)\>/ eval ($temp +_vars{$1}) /ge if $temp_vars{$1}; $content =~ s/\<templ_var ([a-zA-Z0-9\{\'\}_]+)\>/ $temp_vars{ +eval($1)} /ge if $temp_vars{$1}; $content =~ s/\<templ_var ([a-zA-Z0-9\{\'\}_]+)\>/ eval ($1) / +ge if $1; $content =~ s/{{([a-zA-Z0-9\{\'\}_]+)}}/ eval($vars{$1}) /ge i +f $vars{$1}; $content =~ s/{{([a-zA-Z0-9\{\'\}_]+)}}/ $vars{eval($1)} /ge i +f $vars{$1}; $content =~ s/(\$[a-zA-Z0-9\{\'\}_]+)/ eval($vars{$1}) /ge if +$vars{$1}; $content =~ s/(\$[a-zA-Z0-9\{\'\}_]+)/ $vars{eval($1)} /ge if +$vars{$1}; $content =~ s/(\$[a-zA-Z0-9\{\'\}_]+)/ eval($1) /ge; if ($content && ($content =~ /<code>/i && $content =~ /<\/code +>/i)) { while($content =~ /<code>/i && $content =~ /<\/code>/i) { my ($code1,$code2,$_do_code); ($content,$code1) = split /<code>/, $content, 2; ($code2,$ocontent) = split /<\/code>/, $code1, 2; $_do_code = eval($code2); $content = $content . $_do_code . $ocontent; } } if ($content && ($content =~ /<syscode>/i && $content =~ /<\/s +yscode>/i)) { while($content =~ /<syscode>/i && $content =~ /<\/syscode> +/i) { my ($syscode1,$syscode2); ($content,$syscode1) = split /<syscode>/i, $content, 2 +; ($syscode2,$ocontent) = split /<\/syscode>/i, $syscode +1, 2; eval{$syscode2}; $content = $content . $ocontent; } } if ($_add_name) { $content = qq~<!--Start $db_name-->$content<!--End $db_nam +e-->~; } $temp_vars{$db_name} = $content; } $sth->finish(); return(%temp_vars); }
errors:
[Tue Sep 25 08:12:24 2007] web.cgi: Useless use of private variable in + void context at /path/to/user/readin_pagevars.cgi line 35. [Tue Sep 25 08:12:24 2007] web.cgi: Useless use of defined operator in + void context at /path/to/user/readin_pagevars.cgi line 7. [Tue Sep 25 08:12:24 2007] web.cgi: Useless use of defined operator in + void context at /path/to/user/vars_e_subs.conf line 36. [Tue Sep 25 08:12:24 2007] web.cgi: Useless use of defined operator in + void context at /path/to/user/vars_e_subs.conf line 38. [Tue Sep 25 08:12:24 2007] web.cgi: Unquoted string \"yr\" may clash w +ith future reserved word at /path/to/user/vars_e_subs.conf line 103. [Tue Sep 25 08:12:24 2007] web.cgi: Useless use of defined operator in + void context at /path/to/user/vars_e_subs.conf line 344. [Tue Sep 25 08:12:24 2007] web.cgi: Useless use of defined operator in + void context at /path/to/user/vars_e_subs.conf line 346. [Tue Sep 25 08:12:24 2007] web.cgi: Useless use of defined operator in + void context at /path/to/user/vars_e_subs.conf line 348. [Tue Sep 25 08:12:24 2007] web.cgi: Useless use of defined operator in + void context at /path/to/user/vars_e_subs.conf line 350. [Tue Sep 25 08:12:25 2007] web.cgi: Compilation failed in require at w +eb.cgi line 69. [Tue Sep 25 08:12:27 2007] Sess.pm: Ambiguous call resolved as CORE::o +pen(), qualify as such or use & at /path/to/user/md/Sess.pm line 92. [Tue Sep 25 08:12:27 2007] Sess.pm: Ambiguous call resolved as CORE::o +pen(), qualify as such or use & at /path/to/user/md/Sess.pm line 116. + [Tue Sep 25 08:12:27 2007] Sess.pm: Ambiguous call resolved as CORE::o +pen(), qualify as such or use & at /path/to/user/md/Sess.pm line 126.
If I have variables in the database, is there a better way that will not give me those "Useless use of defined operator in void context at ..." errors?

I'm filling up my apache log with those errors, and I don't know a better way to do it. Any pointers would be most excellent!

Thank you,
John

In reply to Reading Variables out of a database. by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.