Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
errors: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); }
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?[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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Reading Variables out of a database.
by ikegami (Patriarch) on Sep 25, 2007 at 17:22 UTC | |
|
Re: Reading Variables out of a database.
by suaveant (Parson) on Sep 25, 2007 at 14:56 UTC |