#!/usr/bin/perl

use strict;
use warnings;
use IO::Handle;

my $all="./all_pages.txt";
my $chk="./checked_pages.txt";

# Files
my $all_pages={};
my $checked=[];
my $to_check=[];

# Read in all of the articles
my $read_all=IO::Handle->new();
open ($read_all, "<$all") or die "Failed to open: [$all], error: $!\n";
while (<$read_all>)
{
	chomp;
	$all_pages->{$_}=1;
}
$read_all->close();

# Read in the new article list. As I see each article, check for a match in
# %old_pages. If found, push the page into '@common'. If not, push it into
# '@only_new'.
my $read_chk=IO::Handle->new();
open ($read_chk, "<$chk") or die "Failed to open: [$chk], error: $!\n";
while (<$read_chk>)
{
	chomp;
	my $article=$_;
	push @{$checked}, $article if exists $all_pages->{$article};
	delete $all_pages->{$article} if $all_pages->{$article};
}
$read_chk->close();

# Now loop through the left over entries in %old_pages and push them into 
foreach my $article (sort {$a cmp $b} keys %{$all_pages})
{
	push @{$to_check}, $article;
}

# Now spit out the results.
print "-=] Checked:\n";
foreach my $article (sort {$a cmp $b} @{$checked})
{
	print $article, "\n";
}
print "\n-=] To check.\n";
foreach my $article (sort {$a cmp $b} @{$to_check})
{
	print $article, "\n";
}

exit;
