I have a module that return SQL statements upon request.

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

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.