Hi all,
I use perl to view a flat file using table in html but it really urly
if some file is blank so i thinh i should replace a blank field with an n/a
so if a comment1 field and comment2 field is blank then put n/a in those field
but it does not work.
Please help me, here is my stuppid code
open (DATA,"PAD.txt") || die ("Can't Open data File \n");
@data=<DATA>;
close DATA;
&header_response;
$x=0;
foreach $line (@data) {
$x++;
($Router, $itemgroup, $itemid, $SFC, $LogOp, $timestamp, $ncdescr
+iption, $nccode, $operator, $comment1, $comment2)=split(/\|/,$line);
if (($comment1 =~ " ") && ($comment2 =~ " ")) {
print "<TR><TD>$x</TD><TD>$Router</TD><TD>$itemgroup</TD><TD>$item
+id</TD><TD>$SFC</TD><TD>$LogOp</TD><TD>$timestamp</TD><TD>$ncdescript
+ion</TD><TD>$nccode</TD><TD>$operator</TD><TD>n/a</TD><TD>n/a</TD></T
+R> \n";
}
elsif (($comment1 != " ") && ($comment2 =~ " ")) {
print "<TR><TD>$x</TD><TD>$Router</TD><TD>$itemgroup</TD><TD>$itemid</
+TD><TD>$SFC</TD><TD>$LogOp</TD><TD>$timestamp</TD><TD>$ncdescription<
+/TD><TD>$nccode</TD><TD>$operator</TD><TD>$comment1</TD><TD>n/a</TD><
+/TR> \n";
}
else {
print "<TR><TD>$x</TD><TD>$Router</TD><TD>$itemgroup</TD><TD>$itemid</
+TD><TD>$SFC</TD><TD>$LogOp</TD><TD>$timestamp</TD><TD>$ncdescription<
+/TD><TD>$nccode</TD><TD>$operator</TD><TD>$comment1</TD><TD>$comment2
+</TD></TR> \n";
}
}
&footer_response;
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.