Hi Monks,

I insert a "Format" into function and reuse this function with different @array, the first return result is pretty good, but the second is worse ~~ no format_top and all format loss..~what happen for it , how to re-use the "Format"??? Thanks
#! perl -w sub WRITE_REPORT{ my ($cat,$name) = @_; my $filename = "$name\_Joblog\.html"; open(OUTPUTLOG, ">$filename") or die "Can't open up myfile: $!\n"; my $jobset = "CATCAT"; format OUTPUTLOG= <tr> <td> @<<<<<< </td> <td> @* </td> <td> @* </td> <td> @* </td> <td> @* < +/td> $a, $b, $c, $d, $e </tr> . format OUTPUTLOG_TOP = @<<<<<<<<<< $jobset <table border="2"> <tr> <th>Job</th> <th>Status</th> <th>Start</th> <th>End</th> <th>Remark</th> </tr> . ########## Control the lines , 3 line must be used!! $old = select OUTPUTLOG; $= = 200; select $old; foreach (@{$cat}){ my @temp = split(/\,/, $_); $a = "$temp[0]"; $b = "$temp[1]"; $c = "$temp[2]"; $d = "$temp[3]"; $e = "$temp[4]"; write OUTPUTLOG; } close(OUTPUTLOG); } my (@x, @y) = (); while(<DATA>){ if(/^AA/){ push (@x, $_) }elsif(/^BB/){ push(@y, $_); } } WRITE_REPORT(\@x, "AA"); WRITE_REPORT(\@y, "BB"); close(DATA) __DATA__ AA,data1,NORMAL,12/08/2008 16:00:31,12/08/2008 16:00:33, AA,data5,NORMAL,13/08/2008 16:00:31,20/08/2008 16:00:33, AA,data4,NORMAL,14/08/2008 16:00:31,32/08/2008 16:00:33, AA,data3,NORMAL,15/08/2008 16:00:31,42/08/2008 16:00:33, AA,data2,NORMAL,16/08/2008 16:00:31,52/08/2008 16:00:33, AA,data5,NORMAL,13/08/2008 16:00:31,20/08/2008 16:00:33, AA,data4,NORMAL,14/08/2008 16:00:31,32/08/2008 16:00:33, AA,data3,NORMAL,15/08/2008 16:00:31,42/08/2008 16:00:33, AA,data2,NORMAL,16/08/2008 16:00:31,52/08/2008 16:00:33, AA,data2,NORMAL,16/08/2008 16:00:31,52/08/2008 16:00:33, BB,data1,NORMAL,12/08/2008 16:00:31,12/08/2008 16:00:33, BB,data5,NORMAL,13/08/2008 16:00:31,20/08/2008 16:00:33, BB,data4,NORMAL,14/08/2008 16:00:31,32/08/2008 16:00:33, BB,data3,NORMAL,15/08/2008 16:00:31,42/08/2008 16:00:33, AA,data2,NORMAL,16/08/2008 16:00:31,52/08/2008 16:00:33, BB,data1,NORMAL,12/08/2008 16:00:31,12/08/2008 16:00:33, BB,data5,NORMAL,13/08/2008 16:00:31,20/08/2008 16:00:33, BB,data4,NORMAL,14/08/2008 16:00:31,32/08/2008 16:00:33, BB,data3,NORMAL,15/08/2008 16:00:31,42/08/2008 16:00:33, AA,data2,NORMAL,16/08/2008 16:00:31,52/08/2008 16:00:33, BB,data1,NORMAL,12/08/2008 16:00:31,12/08/2008 16:00:33, BB,data5,NORMAL,13/08/2008 16:00:31,20/08/2008 16:00:33, BB,data4,NORMAL,14/08/2008 16:00:31,32/08/2008 16:00:33, BB,data3,NORMAL,15/08/2008 16:00:31,42/08/2008 16:00:33, AA,data2,NORMAL,16/08/2008 16:00:31,52/08/2008 16:00:33, BB,data1,NORMAL,12/08/2008 16:00:31,12/08/2008 16:00:33, BB,data5,NORMAL,13/08/2008 16:00:31,20/08/2008 16:00:33, BB,data4,NORMAL,14/08/2008 16:00:31,32/08/2008 16:00:33, BB,data3,NORMAL,15/08/2008 16:00:31,42/08/2008 16:00:33, AA,data5,NORMAL,13/08/2008 16:00:31,20/08/2008 16:00:33, AA,data2,NORMAL,16/08/2008 16:00:31,52/08/2008 16:00:33, BB,data1,NORMAL,12/08/2008 16:00:31,12/08/2008 16:00:33, BB,data5,NORMAL,13/08/2008 16:00:31,20/08/2008 16:00:33, BB,data4,NORMAL,14/08/2008 16:00:31,32/08/2008 16:00:33, BB,data3,NORMAL,15/08/2008 16:00:31,42/08/2008 16:00:33, AA,data2,NORMAL,16/08/2008 16:00:31,52/08/2008 16:00:33, BB,data1,NORMAL,12/08/2008 16:00:31,12/08/2008 16:00:33, BB,data5,NORMAL,13/08/2008 16:00:31,20/08/2008 16:00:33, BB,data4,NORMAL,14/08/2008 16:00:31,32/08/2008 16:00:33, BB,data3,NORMAL,15/08/2008 16:00:31,42/08/2008 16:00:33, AA,data4,NORMAL,14/08/2008 16:00:31,32/08/2008 16:00:33, AA,data2,NORMAL,16/08/2008 16:00:31,52/08/2008 16:00:33, BB,data1,NORMAL,12/08/2008 16:00:31,12/08/2008 16:00:33, BB,data5,NORMAL,13/08/2008 16:00:31,20/08/2008 16:00:33, BB,data4,NORMAL,14/08/2008 16:00:31,32/08/2008 16:00:33, BB,data3,NORMAL,15/08/2008 16:00:31,42/08/2008 16:00:33, AA,data2,NORMAL,16/08/2008 16:00:31,52/08/2008 16:00:33, BB,data1,NORMAL,12/08/2008 16:00:31,12/08/2008 16:00:33, BB,data5,NORMAL,13/08/2008 16:00:31,20/08/2008 16:00:33, BB,data4,NORMAL,14/08/2008 16:00:31,32/08/2008 16:00:33, BB,data3,NORMAL,15/08/2008 16:00:31,42/08/2008 16:00:33, AA,data3,NORMAL,15/08/2008 16:00:31,42/08/2008 16:00:33, AA,data2,NORMAL,16/08/2008 16:00:31,52/08/2008 16:00:33, AA,data5,NORMAL,13/08/2008 16:00:31,20/08/2008 16:00:33, AA,data4,NORMAL,14/08/2008 16:00:31,32/08/2008 16:00:33, AA,data3,NORMAL,15/08/2008 16:00:31,42/08/2008 16:00:33, AA,data2,NORMAL,16/08/2008 16:00:31,52/08/2008 16:00:33, BB,data1,NORMAL,12/08/2008 16:00:31,12/08/2008 16:00:33, BB,data5,NORMAL,13/08/2008 16:00:31,20/08/2008 16:00:33, BB,data4,NORMAL,14/08/2008 16:00:31,32/08/2008 16:00:33, BB,data3,NORMAL,15/08/2008 16:00:31,42/08/2008 16:00:33, BB,data2,NORMAL,16/08/2008 16:00:31,52/08/2008 16:00:33,

In reply to how to re-use "Formats" by benlaw

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.