Loading ...
Sorry, an error occurred while loading the content.

Almost There - A Little More Help, Please?

Expand Messages
  • Ofir
    Hi all, Thank you very much for your help (all of you)! I m almost there...Can someone help? I m reading in a file with 4 lines per record. i.e: Line 1 Line 2
    Message 1 of 2 , Mar 31, 2002
    • 0 Attachment
      Hi all,
      Thank you very much for your help (all of you)!
      I'm almost there...Can someone help?

      I'm reading in a file with 4 lines per record. i.e:
      Line 1
      Line 2
      Line 3
      Line 4
      ... etc ...

      Now, the file has two excessive lines AFTER the last record, and so far - I
      can't remove it.
      When I'm printing out the file content - I have another excessive "blank"
      records. i.e: if the file contains 5 records - I'm getting another - number
      6 counter, and a blank non-exist record. How can I eliminate it?
      Here's the main portion of the code I use so far:

      ######### Get Records2
      sub get_records2 {
      @hdrs = ('Counter','Date','News');
      print "<BR><BR><TABLE BORDER=1 CELLSPACING=1 CELLPADDING=2 CLASS=DATA1
      ALIGN=CENTER DIR=RTL><TR><TH>";
      print join('</TH><TH>',@hdrs);
      print "</TH></TR>\n";

      my $file_name = shift;
      local *FH;
      open(FH,"$file_name") || die "Cannot open $file_name: $!";
      $i = 0;
      $c = 1;
      until (eof FH) {
      my @x = map scalar <FH>, 1 .. 4;
      @x = @x[7,3,1];
      print "<TR CLASS=DATA$i VALIGN=TOP><TD>\n";
      print join("</TD><TD>",@x);
      print "</TD></TR>\n\n";
      $i = $i ? 0 : 1;
      $c++ ;
      }
      close(FH);
      print "</TABLE><BR><BR>";
      print "</BODY>";
      print "</HTML>";
      }
      ######### Get Records2

      Thanks!
      Ofir
    • Fergus Cameron
      ... if i understand your description of the problem correctly then i think this is your problem. the printing of the table row will need to be conditional on
      Message 2 of 2 , Apr 1, 2002
      • 0 Attachment
        > until (eof FH) {
        > my @x = map scalar <FH>, 1 .. 4;
        > @x = @x[7,3,1];
        > print "<TR CLASS=DATA$i VALIGN=TOP><TD>\n";
        > print join("</TD><TD>",@x);
        > print "</TD></TR>\n\n";

        if i understand your description of the problem correctly then i think
        this is your problem. the printing of the table row will need to be
        conditional on having valid data to insert into it.

        p.s. a more descriptive subject would be nice
      Your message has been successfully submitted and would be delivered to recipients shortly.