in reply to Re^6: Combining Ffile:fetch with MySQL
in thread Combining Ffile:fetch with MySQL

updated it to this and it prints all the links, but no saved files in the /data/ folder.
while (my $ref = $query->fetchrow_hashref()) { print "url: $ref->{url}\n"; my $ff = File::Fetch->new(uri=>$ref->{url}); my $where = $ff->fetch( to => '/data/'); } $query->finish;

Replies are listed 'Best First'.
Re^8: Combining Ffile:fetch with MySQL
by hippo (Archbishop) on Jul 25, 2022 at 14:38 UTC
    but no saved files in the /data/ folder.

    Is your /data/ directory really at the root of the filesystem? That would be unusual. Pass it the actual path if not.

    Try printing $ff->error after the call to fetch to see more detail of what's going wrong. See also the Basic Debugging Checklist.


    🦛

      it is a windows machine and it is in the C:\ directory. so C:\data\ is the path. to test that, I updated it to download to both /data/ and a new subdirectory called: /data/documents/ changed it to this:
      #$path='/data/'; $path= '/data/documents/'; while (my $ref = $query->fetchrow_hashref()) { print "url: $ref->{url}\n"; my $ff = File::Fetch->new(uri=>$ref->{url}); my $where = $ff->fetch( to => '$path'); my $error= $ff->error(); print $error;
      and the output is the same. no error messages. changing it from print $error to print $ff, I get the link followed by: File::Fetch=HASH(0x30d2a18)
        my $where = $ff->fetch( to => '$path');

        Again, you are enclosing a variable inside single quotes, so it won't be interpolated. Remove the quotes for more success.

        Here is an SSCCE showing how to use File::Fetch successfully.

        #!/usr/bin/env perl use strict; use warnings; use File::Fetch; use Test::More tests => 1; my $url = 'https://www.perlmonks.org/?part=1;displaytype=displaycode;n +ode_id=11145569;abspart=1'; my $ff = File::Fetch->new (uri => $url); my $loc = $ff->fetch (to => '/tmp/'); ok -f $loc, "Downloaded file to $loc";

        Try examining the return value of fetch like this in your code to find the saved file.


        🦛