You are on page 1of 1

#!

/usr/bin/perl
use strict;
use Config;
#Is necesary dev-perl/libwww-perl
use LWP::Simple;
#Is necesary dev-perl/File-HomeDir
use File::HomeDir;
my $version;
my $versionfile;
my $file = File::HomeDir->my_home . "/.spocheck";
my $url = "https://driverpracticaltest.direct.gov.uk/manage?execution=e3s3";
my $content = get($url);
die "No puedo traer $url" unless defined $content;
if ( $Config{myarchname} eq 'x86_64-linux' ) {
($version) = ( $content =~ /\>spotify-client-qt.*amd64.deb/gi );
}
else { ($version) = ( $content =~ /\>spotify-client-qt.*i386.deb/gi ); }
$version =~ s/>//ig;
if ( -e $file ) { &readfile; }
else { &createupdatefile; }
sub createupdatefile {
open( FILE, ">$file" );
flock( FILE, 2 );
printf FILE $version;
flock( FILE, 8 );
close(FILE);
}
sub readfile {
open( FILE, $file );
$versionfile = ;
close(FILE);
if ( $version ne $versionfile ) {
print "New version available: $version";
&createupdatefile;
}
}
exit;

You might also like