If the version of LWP::UserAgent that was installed does something differently then the version of UserAgent you originally used, the answer is, yes, it could have broken something. However, I've noticed you don't have:

use strict; use warnings;

At the top of your script. So I ran your script and added those two lines and got the following:

Global symbol "@lines" requires explicit package name at - l +ine 8. Global symbol "$out" requires explicit package name at - lin +e 10. Global symbol "@lines" requires explicit package name at - l +ine 10. Global symbol "@lines" requires explicit package name at - l +ine 12. BEGIN not safe after errors--compilation aborted at - line 13. [Fri Feb 13 01:48:06 2004] -: Global symbol "@lines" requires explicit + package name at - line 8. [Fri Feb 13 01:48:06 2004] -: Global symbol "$out" requires explicit p +ackage name at - line 10. [Fri Feb 13 01:48:06 2004] -: Global symbol "@lines" requires explicit + package name at - line 10. [Fri Feb 13 01:48:06 2004] -: Global symbol "@lines" requires explicit + package name at - line 12. [Fri Feb 13 01:48:06 2004] -: BEGIN not safe after errors--compilation + aborted at - line 13.

Now all those errors mean that you're not declaring before using, or that you're not explicitely accessing (i.e. Package::sub instead of sub), and this isn't necessarily the source of your errors. But it's very good practice to use warnings; use strict; at the top of your code because it helps unmask errors.

I would recommend taking the time to go through your script to make it compatible with use strict; use warnings; That may help isolate the problem.

Update: I was thinking about it, and you can compact the following lines of code:

$request = HTTP::Request->new('GET', 'http://www.bom.gov.au/cgi-bin/wr +ap_fwo.pl?IDS10034.txt'); $res = $ua->request($request);

Into:

my $request = $user_agent->get('http://www.bom.gov.au/cgi-bin/wrap_fwo +.pl?IDS10034.txt');

And not to nit pick, but you should always double check your content type. Otherwise you might accidently get a JPEG or something, i.e.:

if ($res->is_error) { $str = $res->message; } else { $str = $res->content; }

Under my example would become:

if ($response->is_success and ($response->content_type eq 'text/html')) { $str = $response->content; } else { $str = "Content type was $response->content_type" unless ($response->content_type eq 'text/html'); $str = $response->status_line unless ($response->is_success); }

Of course, the updates were stylistic and a matter of preference (except for checking content type unless you are absolutely sure you can only get the proper content type). TMTOWTDI


Want to support the EFF and FSF by buying cool stuff? Click here.

In reply to Re: weather script not working by Vautrin
in thread weather script not working by pip

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.