I created a table in our mysql database for page variables, so the pages can load dynamically. I then call certain variables in text that is in a database record. Since I cannot use variables directly in mysql, I put them as merge fields, such as: ##variable## or something. There are several different types of variables, which were created over time, so I have accounted for each of them. Here is the subroutine I wrote to put these into a hash for storage while the system is running. We then later replace each of those merge fields:
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()) +{ if($content =~ /(\$[a-zA-Z0-9\{\'\}_]+)/) { $content =~ s/(\$[a-zA-Z0-9\{\'\}_]+)/eval($temp_vars{$1}) +/ge; $content =~ s/(\$[a-zA-Z0-9\{\'\}_]+)/$temp_vars{eval($1)} +/ge; $content =~ s/(\$[a-zA-Z0-9\{\'\}_]+)/eval($vars{$1})/ge; $content =~ s/(\$[a-zA-Z0-9\{\'\}_]+)/$vars{eval($1)}/ge; $content =~ s/(\$[a-zA-Z0-9\{\'\}_]+)/eval($1)/ge; } if($content =~ /\<templ_var ([a-zA-Z0-9\{\'\}_]+)\>/) { $content =~ s/\<templ_var ([a-zA-Z0-9\{\'\}_]+)\>/eval($va +rs{$1})/ge; $content =~ s/\<templ_var ([a-zA-Z0-9\{\'\}_]+)\>/$vars{ev +al($1)}/ge; $content =~ s/\<templ_var ([a-zA-Z0-9\{\'\}_]+)\>/eval($te +mp_vars{$1})/ge; $content =~ s/\<templ_var ([a-zA-Z0-9\{\'\}_]+)\>/$temp_va +rs{eval($1)}/ge; $content =~ s/\<templ_var ([a-zA-Z0-9\{\'\}_]+)\>/eval($1) +/ge; } if($content =~ /{{([a-zA-Z0-9\{\'\}_]+)}}/) { $content =~ s/{{([a-zA-Z0-9\{\'\}_]+)}}/eval($vars{$1})/ge +; $content =~ s/{{([a-zA-Z0-9\{\'\}_]+)}}/$vars{eval($1)}/ge +; } $content =~ s|<br>|<br />|g; 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); }
I had to go add a bunch of stuff because there were soooo many useless void errors. I know there are modules already that will do this more effieiently, however, I wrote this years ago, have not had time to upgrade the system to a better one. that is on my to-do list for the future though.

I certainly would love any feedback, negative or positive.

thank you.

In reply to Re: use of useless void in context by Anonymous Monk
in thread use of useless void in context 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.