in reply to Re^3: Check website has update file using www::mechanize
in thread Check website has update file using www::mechanize

Yeah it's working but I still have a same problem

my $res=$mech>mirror('download_link'); print " response is :",$res,"\n\n"; # no content

I got download file when i ran but I need whether the file is updated or not, if updated then download otherwise just drop a message

Replies are listed 'Best First'.
Re^5: Check website has update file using www::mechanize
by Tux (Canon) on May 25, 2016 at 11:21 UTC

    I hope that this is just a cut-n-paste error, as that is now what you mean. Missing a dash:

    my $res = $mech->mirror ("download_link"); # ^ there print " response is :", $res, "\n\n"; # no content

    If you are using use strict; and use warnings; running the code would show you.

    As I showed in my action list in this thread, the fact the a page that contains the links is not updated does not mean that the files it links to are not updated.

    You should post more of the real code for us to check if you are checking the right headers.


    Enjoy, Have FUN! H.Merijn

      Yeah Your are correct I pass one link to the mirror as a argument it's actually downloaded and again i pass a second link it's return a hash reference that's "response :HTTP::Response=HASH(0x8b555e4)"

      my $res=$mech->mirror('firstlink','firstfile.zip'); print "response :",$res,"\n\n"; $res=$mech->mirror('secondlink','secondfile.zip'); print "response :",$res,"\n\n";

      How can I change the hash reference to string

      I tried roughly is correct???

      print : response : ",%{$res},"\n\n"; # is correct???

        Hmm, that error should have motivated you to type

        $ perldoc HTTP::Response

        and move on from the knowledge gained

        my $res = $mech->mirror (...); if ($res->is_success) { my $content = $res->decoded_content; # Do something with content } else { warn "Oops: ", $res->status_line; }

        Enjoy, Have FUN! H.Merijn