sub computeSHA1 () { # Passed a file path, opens the file and calculates the SHA1 value my $srcfile = shift; print "DEBUG: computeSHA1: arrived\n" if ($debug); my $sha1post = Digest::SHA1->new; open my $filehandle, $srcfile or &usage("computeSHA: Failed to open " . $srcfile . ": " . $!, 2); $sha1post->addfile($filehandle); print "DEBUG: downloadSHA1: Calculating SHA1 for $srcfile\n" if ($debug); close $filehandle; return $sha1post->hexdigest; } sub downloadSHA1 () { # Passed a URL for a file, looks for the SHA1 file and returns the value my $url = shift; print "DEBUG: downloadSHA1: arrived\n" if ($debug); my $SHAurl = $url . ".sha1"; my $browser = LWP::UserAgent->new; # Get the SHA1 value from $SHAurl my $SHAcall = $browser->get($SHAurl); print "DEBUG: downloadSHA1: Getting SHA1 from $SHAurl\n" if ($debug); &usage("downloadSHA1: Could not fetch SHA1 at " . $SHAurl, 5) unless $SHAcall->is_success; return $SHAcall->content; }