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

my $ff = File::Fetch->new(uri=> '$ref' );

You have potentially 2 errors here. Firstly you are enclosing $ref in single quotes which prevent interpolation. Just lose the quotes entirely. Secondly, my understanding is that you need to pass $ref->{url} as the argument to new() rather than just $ref. Try those fixes and see if you get any further.


🦛

Replies are listed 'Best First'.
Re^7: Combining Ffile:fetch with MySQL
by justin423 (Scribe) on Jul 24, 2022 at 23:13 UTC
    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;
      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)