<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Thanks Steve.&nbsp; Yes, putting the values in the parameter is a brilliant idea.&nbsp; I will make the change.<BR><BR>--- On <B>Tue, 7/28/09, Steve Fink <I>&lt;sphink@gmail.com&gt;</I></B> wrote:<BR>
<BLOCKQUOTE style="BORDER-LEFT: rgb(16,16,255) 2px solid; PADDING-LEFT: 5px; MARGIN-LEFT: 5px"><BR>From: Steve Fink &lt;sphink@gmail.com&gt;<BR>Subject: Re: [sf-perl] Referencing a variable???<BR>To: "San Francisco Perl Mongers User Group" &lt;sanfrancisco-pm@pm.org&gt;<BR>Date: Tuesday, July 28, 2009, 5:25 PM<BR><BR>
<DIV id=yiv731637211>If you restructure your message, you'll answer yourself:<BR><BR>
<DIV>&gt; $$parmName has no value.&nbsp; What am I doing wrong?<BR><BR>&gt; I have 10 program variables namely $parm[1-10]</DIV><BR>Yep, that's what you're doing wrong.<BR><BR>Your code should work. The problem must be earlier. But it's not the best way to go about this anyway. You would be much better off putting those parameters into an array @params and then<BR><BR><SPAN style="FONT-FAMILY: courier new, monospace">&nbsp; for my $param (@params) {</SPAN><BR style="FONT-FAMILY: courier new, monospace"><SPAN style="FONT-FAMILY: courier new, monospace">&nbsp; &nbsp; my ($hardValue, $replaceValue) = split(/~!~/, $param);</SPAN><BR style="FONT-FAMILY: courier new, monospace"><SPAN style="FONT-FAMILY: courier new, monospace">&nbsp; &nbsp; $<SPAN>sqlString</SPAN> =~ s/~$hardValue~/$replaceValue/g;</SPAN><BR style="FONT-FAMILY: courier new, monospace"><SPAN style="FONT-FAMILY: courier new, monospace">&nbsp; }</SPAN><BR style="FONT-FAMILY: courier new,
 monospace"><BR>or if you really need to insert them positionally,<BR><BR><SPAN style="FONT-FAMILY: courier new, monospace">&nbsp; for my $param (@params) {</SPAN><BR style="FONT-FAMILY: courier new, monospace"><SPAN style="FONT-FAMILY: courier new, monospace">&nbsp;&nbsp;&nbsp; if (defined $param) {</SPAN><BR style="FONT-FAMILY: courier new, monospace"><SPAN style="FONT-FAMILY: courier new, monospace">&nbsp; &nbsp; &nbsp; my ($hardValue, $replaceValue) = split(/~!~/, $param);</SPAN><BR style="FONT-FAMILY: courier new, monospace"><SPAN style="FONT-FAMILY: courier new, monospace">&nbsp; &nbsp; &nbsp; $sqlString =~ s/~$hardValue~/$replaceValue/g;</SPAN><BR style="FONT-FAMILY: courier new, monospace"><SPAN style="FONT-FAMILY: courier new, monospace">&nbsp;&nbsp;&nbsp; }</SPAN><BR style="FONT-FAMILY: courier new, monospace"><SPAN style="FONT-FAMILY: courier new, monospace">&nbsp; }</SPAN><BR style="FONT-FAMILY: courier new, monospace"><BR>The huge, huge
 benefit, beyond slightly prettier code, is that you can then put a "use strict;" at the top and find mistakes like the spelling mistake that is probably causing your current problem.<BR><BR><BR>
<DIV class=gmail_quote>2009/7/28 Peter Loo <SPAN dir=ltr>&lt;<A href="http://us.mc329.mail.yahoo.com/mc/compose?to=loopeter@yahoo.com" rel=nofollow target=_blank ymailto="mailto:loopeter@yahoo.com">loopeter@yahoo.com</A>&gt;</SPAN><BR>
<BLOCKQUOTE style="BORDER-LEFT: rgb(204,204,204) 1px solid; MARGIN: 0pt 0pt 0pt 0.8ex; PADDING-LEFT: 1ex" class=gmail_quote>
<TABLE border=0 cellSpacing=0 cellPadding=0>
<TBODY>
<TR>
<TD style="FONT-FAMILY: inherit; font-size-adjust: inherit; font-stretch: inherit" vAlign=top>
<DIV>Hi All,</DIV>
<DIV>&nbsp;</DIV>
<DIV>I have done this once before and can't seem to remember how I did it.</DIV>
<DIV>&nbsp;</DIV>
<DIV>I have 10 program variables namely $parm[1-10].&nbsp; Then I try to check if they are set using a loop like so:</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; for ( my $x = 1; $x &lt;= $maxParm; $x++ ) {<BR>&nbsp;&nbsp;&nbsp; my $parmName = "parm" . $x;<BR>&nbsp;&nbsp;&nbsp; if ( $$parmName ) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; my ($hardValue, $replaceValue) = split(/~!~/, $$parmName);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $sqlString =~ s/~$hardValue~/$replaceValue/g;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>&nbsp;</DIV>
<DIV>$$parmName has no value.&nbsp; What am I doing wrong?</DIV>
<DIV>&nbsp;</DIV>
<DIV>Thank you all in advance.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Peter</DIV></TD></TR></TBODY></TABLE><BR><BR>_______________________________________________<BR>SanFrancisco-pm mailing list<BR><A href="http://us.mc329.mail.yahoo.com/mc/compose?to=SanFrancisco-pm@pm.org" rel=nofollow target=_blank ymailto="mailto:SanFrancisco-pm@pm.org">SanFrancisco-pm@pm.org</A><BR><A href="http://mail.pm.org/mailman/listinfo/sanfrancisco-pm" rel=nofollow target=_blank>http://mail.pm.org/mailman/listinfo/sanfrancisco-pm</A><BR><BR></BLOCKQUOTE></DIV><BR></DIV><BR>-----Inline Attachment Follows-----<BR><BR>
<DIV class=plainMail>_______________________________________________<BR>SanFrancisco-pm mailing list<BR><A href="http://us.mc329.mail.yahoo.com/mc/compose?to=SanFrancisco-pm@pm.org" ymailto="mailto:SanFrancisco-pm@pm.org">SanFrancisco-pm@pm.org</A><BR><A href="http://mail.pm.org/mailman/listinfo/sanfrancisco-pm" target=_blank>http://mail.pm.org/mailman/listinfo/sanfrancisco-pm</A><BR></DIV></BLOCKQUOTE></td></tr></table><br>