Monks, I am a newbie so please try to be patient with me. I am comparing two html tables in which one has a list of all the users and another has a list of users that completed a task. My goal is to create one list of users that have not completed the task. My code works, however I'm sure there is a much cleaner way of doing it. I appreaciate any suggestions. Thanks
#!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; use HTTP::Cookies; use HTTP::Request::Common; use HTML::TableExtract; use URI; my $cookie = "cookie.txt"; my $ua = LWP::UserAgent->new; $ua->cookie_jar(HTTP::Cookies->new(file => $cookie , autosave => 1)); my $list = $ua->simple_request(POST '$foo', [ username=>'username', password=>'password', action => 'Login', ]); my $u = $list->header('location') or die "missing location: ", $list-> +as_string; $u = URI->new_abs( $u , $list->base ); my $list2 = $ua->request(GET "$foo2"); $list = $ua->request(GET $u); my %employee; my ($email, $host, $name); #creates hash of entire group my $te = new HTML::TableExtract(headers => [qw(Name Email)]); $te->parse($list->as_string); foreach my $ts ($te->table_states) { foreach my $row ($ts->rows) { foreach my $col (@$row){ chomp($col); $col =~ s/.//; $col =~ s/\s+?$//; if ($col =~ /@\S+/){ $col =~ s/,/./g; $email = $col; if ($email =~ /@(\S+)/){ $host = $1;}} elsif($col =~ /(\S+),\s+(\S+)/){ $name = $2 . " " . $1;} else{ $email="dublicate"; $host= "dublicate";}} $employee{$email}="$host##$name#$email";}} #array of people completed task my @finish; $te = new HTML::TableExtract(headers =>[qw(Email)]); $te->parse($list2->as_string); foreach my $ts ($te->table_states){ foreach my $row ($ts->rows){ foreach my $col (@$row){ push @finish, $col;}}} #deletes all those that completed module8 from hash foreach my $n (@finish){ foreach my $emp (keys %employee){ if ($n eq $emp){ delete $employee{$emp}; last;}}} open (LIST, ">IncompleteTask.txt"); foreach my $emp(keys %employee){ print LIST "$employee{$emp}\n";}

In reply to comparing two tables by Anonymous Monk

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.