I'm moving our company's ASP pages from VBS to Perlscript (for a variety of reasons, not all related to Perlscript's simpler interface for doing simple things and better overall power and compactness). Anyway, it seems to be ignoring my setting a variable's value. The code isn't extraordinarily long, so I'm posting all the relevant part here. In short, the $rtype variable, even though it seems to be "row", never gets to the elsif statement.
Results can be seen at
kbw.com. Forgive the current mess, I've put in a few statements to change the output so I could see what's going on. So far, it hasn't helped:
#First, set a bunch of semi-constants (apologies to those offended by
+the lack of conventions here).
$tdo = "<td>";
$tdc = "<\/td>";
$tblo = "<table width=\"525\" border=\"0\" cellpadding=\"5\" cellspaci
+ng=\"0\">";
$hro = "<tr bgcolor=\"#0065ce\">";
$rc = "<\/tr>";
$ro = "<tr>";
$htd = "<td valign=\"top\"><b><font size=\"2\" color=\"white\" face=\"
+Arial,Helvetica,Geneva,Swiss,SunSans-Regular\">";
$htdc = "<\/font><\/b>".$tdc;
## Now the actual working code
$time=0;
$Response->write($tblo); ## Write table (works)
$filename = $Server->MapPath('./data/test.dat'); ## map file
open(fileREAD, $filename); #open file (works)
while ($line = <fileREAD>){
$rtype = "";
@array = split "\t", $line;
$rtype = pop @array;
$time ++;
$Response->write("<tr><td>line = ".$line."&".$rtype."&".$time."<\/td><
+\/tr>"); ## t-shoot
#$Response->write("rtype = ".$rtype);
if ($rtype = "header "){
$Response->write($hro);
foreach (@array){
#$Response->write("<tr><td>line = ".$line."&".$rtype."
+&".$time."<\/td><\/tr>");
$Response->write($htd.$_.$rtype.$htdc);
#$Response->write("<tr><td>line = ".$line."&".$rtype."
+&".$time."<\/td><\/tr>");
}
}
elsif ($rtype = "row "){
$Response->write($ro);
foreach (@array){
$Response->write($td.$_.$tdc);
}
}
$Response->write($rc);
Any help appreciated
Thanks
Sam
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.