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

ok. I am getting somewhere. here is the code:
while (my $ref = $query->fetchrow_hashref()) { print "url: $ref->{url}\n"; my $ff = File::Fetch->new(uri=> '$ref' ); my $where = $ff->fetch(to => '/data'| \$scalar) ;

when I run it with the where commented out, it prints the correct URL's, but errors out on each one with hostname required when fetching from ''

running it with the $where uncommented, I get the same error, but it drops out on the first line of data with a can't call method Fetch on an undefined value.

Replies are listed 'Best First'.
Re^6: Combining Ffile:fetch with MySQL
by hippo (Archbishop) on Jul 24, 2022 at 22:34 UTC
    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.


    🦛

      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.


        🦛