Here's the offending line:

#######
$TXT .= swrite("@<<<<<<<<<<<<<<<<<<<<  @>>>>>>>>> @>>>>>",$rec, 
$stats{virus}->{$rec}, $percent)."%\n" if $text;
#######

The @<<<<<<<<<<<<<<<<<<<< part is telling format to print up to 21 characters 
of $rec and truncate the rest, left justifying it.  If you want to make the 
printout of $rec longer, add more of these: '<' to that field.


-----Original Message-----
From: Chris [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 08, 2006 6:05 PM
To: beginners@perl.org
Subject: Help with line length in script

I use a script that generates stats for clamav. It generates both txt and 
html output.  The problem is that the line length in the txt and html 
output differ. For instance in the txt output it shows this: (the numbers 
differ because the files were generated at different times)

Email.ScamS.Gen005.Sa           6   9.09%

While in the html file its shows this:

Email.ScamS.Gen005.Sanesecurity.06041100        7               9.46%

I 'think' this is where this comes from, but knowing very, very little about 
perl I may be wrong.

### VIRUS COUNTS

        $TXT .= keys ( %{$stats{virus}} ) . " Virus Types Detected\n" if $text;
        $TXT .= "------------------------------------------\n" if $text;
        
        if ($html) {
                print "<table border=0><tr><Th COLSPAN=4 bgcolor=\#666699><font 
color=\#FFFFFF size=4>" . keys ( %{$stats{virus}} ) . " Virus Types 
Detected</font></th><TH align=center>";
        }

        foreach my $rec ( sort {$stats{virus}{$b}<=>$stats{virus}{$a}}  keys 
%{$stats{virus}} ) {
                my $percent = sprintf ("%.2f", (($stats{virus}->{$rec} / 
$stats{count}) * 
100));
                1 while $stats{virus}->{$rec} =~ s/(.*\d)(\d\d\d)/$1,$2/;
                $TXT .= swrite("@<<<<<<<<<<<<<<<<<<<<  @>>>>>>>>> @>>>>>",$rec, 
$stats{virus}->{$rec}, $percent)."%\n" if $text;

                if ($html) {
                        print "<tr><td align=left bgcolor=\#9999FF>";
                        print "$rec</td>";
                        print "<td align=right bgcolor=\#DCDCEE>";
                        print $stats{virus}->{$rec} . "</td><td></td><td 
ALIGN=RIGHT 
bgcolor=\#CCCCFF>$percent". "%";
                        print "</td></tr>\n";
                }

        }
                print "</TABLE></td>" if $html;

If the whole script is needed let me know and I'll upload it somewhere.

Thanks for any advice

-- 
Chris
Registered Linux User 283774 http://counter.li.org
19:51:46 up 25 days, 7:52, 1 user, load average: 0.18, 0.50, 0.45
Mandriva Linux 10.1 Official, kernel 2.6.8.1-12mdk



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to