Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/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";}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: comparing two tables
by Hofmator (Curate) on Jan 31, 2003 at 21:03 UTC |