#!/usr/bin/perl
use strict;
my $TEMP='/tmp';my $COMMAND;my $confirm;
sub execute_command();
my $URL=shift;my $FILENAME=shift;
$FILENAME='gdown' if $FILENAME eq '';
execute_command();
if (-s $FILENAME < 100000) { # only if file isn't the download yet
    open fFILENAME, '<', $FILENAME;
    foreach (<fFILENAME>) {
        if (/confirm=([^;&]+)/) {
            $confirm=$1; last;   }    }
    close fFILENAME;
    $URL=~s/confirm=([^;&]+)/confirm=$confirm/;
    execute_command();    }
sub execute_command() {
    $COMMAND="wget --no-check-certificate --load-cookie $TEMP/cookie.txt --save-cookie $TEMP/cookie.txt \"$URL\"";
    $COMMAND.=" -O \"$FILENAME\"" if $FILENAME ne '';
    `$COMMAND`; return 1;    }
