Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I have a file it consists of email addresses. pls see below cat /tmp/PassedCLEAN_2.txt

user@domain.com nil@domain.com nil@domain.com lasa@domain.com lasa@domain.com ra@anydomain.com <> lasa@domain.com sudhe@domain2.com char@domain1.com lasa@domain.com anu@domain.com anu@domain.com

I read it from start to end. when there are duplicates, I count one by one.

e.g nil@domain.com nil@domain.com user@domain.com <> in this case - nil@domain.com has 2 mails. user@domain.com has 1 mail +and <> has 1 mail. I hope U got it. my below senders.cgi works. it gives the output as follows to my web page.
<> 1 anu@domain.com 2 char@domain1.com 1 lasa@domain.com 4 nil@domain.com 2 ra@anydomain.com 1 sudhe@domain2.com 1 user@domain.com 1

How Can I print that data in side a table. I also need 2 tables headers Senders Messages Under Senders, ALL sender email addresses should be displayed. Under Messages their Counts should be displayed. or I need a Horizontal Bar char with email addresses and their Message Counts. some thing better is needed.

This is my sender.cgi code

#!/usr/bin/perl #senders.cgi use CGI ':standard'; use strict; use warnings; print header(); print start_html(-title =>'Senders', -bgcolor=>'#95B8DB'); print "<br />"; print "<h1><center>Senders \n\n\n</center></h1>"; print "<br />"; system("sudo grep -E 'Passed CLEAN.* ->.*' /var/log/maillog | grep -v +root@ > /tmp/PassedCLEAN.txt"); system("sudo awk '{print \$12}' /tmp/PassedCLEAN.txt > /tmp/PassedCLEA +N_1.txt"); system('sed -e "s/<\(.*\@.*\)>/\1/g" /tmp/PassedCLEAN_1.txt > /tmp/Pas +sedCLEAN_2.txt'); my $logfile = '/tmp/PassedCLEAN_2.txt'; open my $fh, '<', $logfile or die "Could not open $logfile : $!"; my %count=(); while (my $line = <$fh>) { foreach my $word (split /\s+/, $line) { ++$count{$word}; #print "$word\n"; #print "<br />"; #print " \n"; } } print "<br />"; print "<br />"; for my $word (sort keys %count) { print "$word $count{$word}\n"; #print "$count{$word}\n"; print "<br />"; print " \n"; } close $fh; print "<br />"; print end_html;

How can I get it done? Hope to hear from you.


In reply to OUTPUT Data to a table or horizontal bar chart by theravadamonk

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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (8)
    As of 2021-03-01 17:15 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      My favorite kind of desktop background is:











      Results (15 votes). Check out past polls.

      Notices?