in reply to <FILE> Questions

In addition to the previous post, I don't see where you are saving or outputting the result of your variable translation in either of your examples .. did you leave that out for simplicity's sake?

--t. alex
Life is short: get busy!

Replies are listed 'Best First'.
Re: <FILE> Questions
by powerhouse (Friar) on Nov 11, 2003 at 05:06 UTC
    Thank you so much!!!

    Yeah, I saved it for ease, I guess I should have put the whole subroutine in there.

    I'm saving it after the 2nd while statement, inside the first one(that gets stuff from the db) into a hash like this:$template{$dbname} = $_content;

    I'm taking it out of the database, with $content. I'm putting it in the $_content from the while <> statement.

    I got it to work like this:
    The Whole Subroutine that is getting data from the database, settings and everything:
    sub Get_Page_Vars { my ($temp_vars,$type) = @_; $sth = $dbh->prepare (qq{ SELECT `name`,`value`,`add_name` FROM `p +age_vars` WHERE (`type` OR `type2`) = ? }); $sth->execute($type); # I know I should have done this different : +o) while(my ($db_name,$content,$_add_name) = $sth->fetchrow_array()) +{ $content =~ s/\<templ_var ([a-zA-Z0-9\{\'\}_]+)\>/ eval ($vars +{$1}) /ge if $vars{$1}; $content =~ s/{{([a-zA-Z0-9\{\'\}_]+)}}/ eval ($vars{$1}) /ge +if $vars{$1}; if ($_add_name) { $content = qq~<!--Start $db_name-->$content<!--End $db_nam +e-->~; } $temp_vars{$db_name} = $content; } $sth->finish(); return(%temp_vars); }


    I don't know why I did not think of the things you suggested, I thought about doing it, but could not call to mind how to try it. Thank you for your advice, tips and comments. I really appreciate it!

    thx,
    Richard