in reply to Detecting for HTTP pages code changes

Another option, which has the advantage that it will still work properly if the script is interrupted and restarted, is the storable module. This will allow you to easily save variables as a file and retrieve them later, like a very crude database. It might look something like this:

use storable; my $results = retrieve('results_store'); sub check_site { my $domain = shift; my $current_result = check_domain($domain); my $last_result = $results->{$domain}; if (($last_result == 200 || !$last_result) && $current_result == 400 +) { send_email($domain); } if ($last_result != $current_result) { $results->{$domain} = $current_result; store $results, 'results_store'; } }

$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest";
$nysus = $PM . ' ' . $MCF;
Click here if you love Perl Monks

Replies are listed 'Best First'.
Re^2: Detecting for HTTP pages code changes
by afoken (Chancellor) on Jan 16, 2018 at 21:05 UTC
    use storable;

    That should be use Storable;. The other line works only accientally.

    I would not use Storable, for a simple reason: It depends on the currently used perl version. Update or downgrade perl and you might get into trouble. There are many other options that don't have this problem. Most of them also allow switching to a different language, or to combine tools build from different languages.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)