Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Lite SELECTed strings don't like to be with Sir WWW::Google::Images

by fernandes (Monk)
on Feb 21, 2012 at 02:32 UTC ( [id://955215]=perlquestion: print w/replies, xml ) Need Help??

fernandes has asked for the wisdom of the Perl Monks concerning the following question:

UPDATE: For those who may be crossing in the same shadows, while no Monk gives His/Her wisdom, I'm going to look for green land at REST::Google::Search.

Dear Honorable Monks,

I'm trying to "shift" SELECTed strings to a function where $result = $foo->bar(shift), but nothing happens. Foreach works fine; I can print the strings from the database. Calling getpic('some arbitrary utf8') also works well. But together the couple doesn't get married. Some help?

#!/usr/bin/perl -w use strict; use utf8; use WWW::Google::Images; use DBI; use Text::Unaccent::PurePerl; my $agent; my $result; my $image; my $count; my $save_content; my $dbargs; my $text; $agent = WWW::Google::Images->new(server => 'images.google.com.br',); sub getpic{ $result = $agent->search(unac_string(shift), limit => 1); while ($image = $result->next()) { $count++; $image->save_content(base => 'image'.$count); } $count = 0; return(); } my $dbh = DBI->connect("dbi:SQLite:dbname=/my/path/.ht.sqlite","","",$ +dbargs); my $all = $dbh->selectall_arrayref("SELECT column FROM table"); foreach my $row (@$all) { ($text) = @$row; getpic($text); }
also works well. But together the couple doesn

Replies are listed 'Best First'.
Re: Lite SELECTed strings don't like to be with Sir WWW::Google::Images
by Corion (Patriarch) on Feb 21, 2012 at 08:14 UTC

    When looking at such a problem, I try to simplify it.

    1. Is DBI relevant to the problem? Replace ->selectall_arrayref with canned results.
    2. Is WWW::Google::Images relevant to the problem? Replace it with print.
    3. Is Text::Unaccent::PurePerl relevant to the problem? Eliminate its use.

    After that, you should have a small, self-contained program that still exhibits the same problem. Far more often the case is that while eliminating other factors I find the true cause and fix the bug.

      Thank you by the methodological recommendation. Usually I think most of us do something similar. Like isolating pieces, making them work alone to see what happens.

      But, the problem with Rousse's module is one and only one, and it is very simple: if you think you may be fighting the biggest IT company in the world, the biggest IT company in the world will actually think you are fighting it.

      For those future prayers who come here after walking on the same shadows, I have now a complete testimony: going REST::MyGodDamPowerful-lestITCompany::Search::Images will bring you back.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://955215]
Approved by aufflick
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2024-04-18 10:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found