I am using a script to look up information from a txt file,
each record on a separate line.
It works but i cant get an if statement to work.

I want basically

IF $es equals "$ 0.00 " then don't display a form.
But if it doesnt equal that then do display
a form the segment of the code looks like this:

if($es =~ /\b$ 0.00 \b/) {print "

which is contained about half way through the following routine..
can someone please show me how to write the proper if statement
sub searchcustomer { open (HANDLE, $datafilename) or &diedatafilenotfound; @data = <HANDLE>; close(HANDLE); $max = scalar (@data); $counter = 0; $found = 0; while ($counter <= $max) { $line = $data[$counter]; $jn = substr ($line, 0, 10); $ph = substr ($line, 10, 10); $ag = substr ($line, 20, 10); $na = substr ($line, 30, 10); $pr = substr ($line, 40, 10); $es = substr ($line, 50, 10); $ad = substr ($line, 60, 10); $st = substr ($line, 70, 65); $cm = substr ($line, 135, 65); $counter++; if (index($jn, $FORM{jobnumber}) != -1) {if (index($ph, $FORM{phnumber}) != -1) {print "<table border=1 bordercolor=888888 cellpadding=0 cellspacin +g=0><tr><td><table width=450> <tr><td width=0><b>Job Number: </b></td> <td width=100%>$j +n</td></tr> <tr><td width=0><b>Name: </b></td> <td width=100%>$n +a</td></tr> <tr><td width=0><b>Phone: </b></td> <td width=100%>$p +h</td></tr> <tr><td width=0><b>Agency: </b></td> <td width=100%>$a +g</td></tr> <tr><td width=0><b>Product: </b></td> <td width=100%>$p +r</td></tr> <tr><td width=0><b>Estimate: </b></td> <td width=100%>$e +s</td></tr> <tr><td width=0><b>Amount Due: </b></td> <td width=100%>$a +d</td></tr> <tr><td width=0><b>Status: </b></td> <td width=100%>$s +t</td></tr> <tr><td width=0><b>Comments: </b></td> <td width=100%>$c +m</td></tr> </table></td></tr> </table><br>\n"; $found = 1; } } } if($es =~ /\bone\b/) {print " <form action=/cgi-bin/FormMail.pl method=post name=accept_estimate_cos +t target=_self id=accept_estimate_cost> <input type=hidden name=job_number value=$jn /> <input type=hidden name=phone_number value=$ph /> <input type=hidden name=agency value=$ag /> <input type=hidden name=product value=$pr /> <input type=submit value='Accept Estimate' name=I_accept_the_Estimat +e> </form> <form action=/cgi-bin/FormMail.pl method=post name=accept_estimate_c +ost target=_self id=accept_estimate_cost> <input type=hidden name=job_number value=$jn /> <input type=hidden name=phone_number value=$ph /> <input type=hidden name=agency value=$ag /> <input type=hidden name=product value=$pr /> <input type=submit value='Decline Estimate' name=I_decline_the_Estim +ate> </form> </td></tr> <br>\n";} if ($found == 0) {print "Sorry, no match was found<br>\n";} print "<a href=$ENV{REQUEST_URI}>Click Here</a> to search again

Edit kudra, 2002-08-05 Added a readmore tag


In reply to How to use IF by jdawes

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.