Calling module (Mason component):
<%args> $action => '' </%args> <%perl> use strict; use warnings; use lib "/home/httpd/starfrontiers/modules"; use SQLlib; use DBI; # is user logged in? If so, get user id my $auid = $m->comp('auth.mas'); my $dbh2 = $m->comp('dbh2.mas'); # get statement defined from form my $sql = SQLlib->new; my $statement = $sql->$action(); #print "statement = ".$statement; dbh($statement, $dbh2); $m->redirect("/wiki/access_granted.html"); $m->auto_send_headers(0); $m->clear_buffer; $m->abort; sub dbh{ my ($statement, $dbh2) = @_; my $sth = $dbh2->prepare($statement) or die "dbh2 = $dbh2 Couldn't + prepare statement: $statement ".$dbh2->errstr; $sth->execute or die "dbh2 = $dbh2 Couldn't execute statement: $st +atement ".$dbh2->errstr; return $sth; } </%perl>
Module snippet
sub insert_lexicon{ my ($self) = @_; $statement = 'INSERT INTO lexicon ( word, meaning, auid) VALUES( \'$word\', \'$meaning\', \'$auid\');'; return ($statement); }
The statement has variables that are passed to the component. Currenlty the insert statement works but, the string "$word" and "$meaning" are literally inserted. In the module I need the variables to be literal strings but, once returned to the component I need the variables to be their actual values. Does that make sense? Is there a better way?
Neil Watson
watson-wilson.ca
In reply to Module and variable place holders? by neilwatson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |