I have the following code, I want to run it 20 times in a loop and replace all the occurences of number'1's in the $hashRecordPtr's with the $count variable.
I'm stuck with the syntax for this.
Can someone please help me at all? It will save me a few hundred lines of code if I can understand this one. :-)
$count=0; while ($count < 20){ $count+=1; if ($$hashRecordPtr{'price_product1'} ne "" ) { print "<tr bgcolor=\"#EDEFF5\">"; if ($$hashRecordPtr{'connection1_description'} ne ""){ print<<"CONNECTION1"; <td valign="middle" align="center" width="78">$$hashRecordPtr{'connect +ion1_size1'}</td> CONNECTION1 } if ($$hashRecordPtr{'connection1_description'} ne ""){ print<<"CONNECTION2"; <td width="78" align="center" valign="middle">$$hashRecordPtr{'connect +ion2_size1'}</td> CONNECTION2 } print "<td width=\"78\" align=\"center\" valign=\"middle\">$$hashRecor +dPtr{'part_number1'}</td>"; if ($$hashRecordPtr{'part_reference1'} ne ""){ # ie its a pack not ind +. print<<"PARTREF"; <td width="78" align="center" valign="middle">$$hashRecordPtr{'part_re +ference1'}</td> PARTREF } if ($$hashRecordPtr{'pack_qty1'} > 2){ # ie its a pack not ind. print<<"PACK"; <td width="78" align="center" valign="middle">$$hashRecordPtr{'pack_qt +y1'}</td> PACK } print<<"HTML3"; <form name="prod_1" action="shoppingBasket2.cgi" method="post"> <td width="68" align="center" valign="middle">&pound;$$hashRecordPtr{' +price_product1'}</td> <td width="72" align="center"> <select name="order_qty"> <option value="1" selected>1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select> </td> <td width="98" align="center" bgcolor="#EDEFF5"><a href=\"javascript: +validateUserAdd(prod_1)\">Add To Basket</a></td> <input type="hidden" name="action" value="add"> <input type="hidden" name="product_id" value="$$hashRecordPtr{'product +_id'}"> <input type="hidden" name="product_details" value="$$hashRecordPtr{'sh +ort_details'} ($$hashRecordPtr{'code1'})"> <input type="hidden" name="code" value="$$hashRecordPtr{'code1'}"> </tr> </form> HTML3 } #cut out from here }

2006-06-13 Retitled by planetscape, as per Monastery guidelines

( keep:0 edit:7 reap:0 )

Original title: 'Interpolation'


In reply to Interpolation in a hash key by pickledegg

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.