NB: This applies to your next reply, as well as to the above... and, I hope, provides some insight on how better to obtain the assistance you seek.
Please provide exact output; not vague descriptions when you say you've tried to understand a reply from a Monk. "I couldn't see... does NOT tell us what you DID see. Since my understanding of your problem may be defective, you need to tell us specifics.
Gimmé ("give me...") questions like "what do you mean" are less than welcome: The Monastery's mission is to help you (and others with questions) learn how to solve problems. I meant that the indenting obscures the structure of your code, but this an issue about which you might have garnered a clue by reading some other code rather than merely asking someone to spoon-feed you an answer.
Similarly, from your next reply, "...I basically need to change the address from which I am doing the requests in the script, isn't it? Would you be so kind to tell me where I could find some examples of this?" reflects no effort on your part represents a pair of "gimmés.
Please read On asking for help and How do I post a question effectively?; visit the Tutorials section; and -- not least of all -- try some self-help, even if it results only in better-framed questions.
And since you describe yourself as "real newbie in Perl," you may wish to start by coding solutions to the exercises in something like Learning Perl (commonly also available from other vendors, including used-book emporia) or working thru one of the (many) on-line courses that are made freely available from university-level CS programs.
Update (forgot to mention this earlier): Among the practices to adopt early: use strict; -- always, until you know a truly good reason to omit the stricture. Doing so will let Perl itself point out many mistakes, such as those that exist in your code. Correcting those that pop up initially (failure to declare variables with my... and company) will lead to your discovery of several more problems whose resolution will also move you forward to the pont where your code will actually start to produce the results you seek:
Data will save to data_uk.txt
Search term is hello.
Number of results 1-1-2012 : 8050
Can't use string ("data_uk.txt") as a symbol ref while "strict refs" i
+n use at 1118172.pl line 67.
At the point in debugging where the code produces the above result, there's still "fixing" to be done ... but by the time you get there, you should be able to complete the repairs.
++$anecdote ne $data
Questions containing the words "doesn't work" (or their moral equivalent) will usually get a downvote from me unless accompanied by:
- code
- verbatim error and/or warning messages
- a coherent explanation of what "doesn't work actually means.