in reply to Problem parsing through downloaded web pages

The weird chars at the beginning of the file are, as I have learned, a BOM. The file is in fact unicode (UCS-2LE ?). Try something like
use Encode qw(encode); ... #my $thearesp = $theresponse->content; my $thearesp = encode("iso-8859-1", decode("UCS-2LE", $theresponse->co +ntent));

See Encode.

Some nits:

--shmem

1)this prefix is often used in other languages to denote a variable holding a scalar, but it's not needed in Perl: the $ already does this.

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Replies are listed 'Best First'.
Re^2: Problem parsing through downloaded web pages
by malomar66 (Acolyte) on Jan 05, 2007 at 17:16 UTC
    I did as you recommended and got the following error: Undefined subroutine &main::decode called at temp.pl line 20, <FIRMS> line 33. This persisted after I installed the encode module that you linked to.

      Did you read the documentation of Encode?

      use Encode qw(encode decode);

      fixes the problem. The line

      my $thearesp = encode("iso-8859-1", decode("UCS-2LE", $theresponse->co +ntent));

      uses the functions encode and decode from Encode, which by default aren't exported. You would have figured out surely, had you read the docs.

      --shmem

      _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                    /\_¯/(q    /
      ----------------------------  \__(m.====·.(_("always off the crowd"))."·
      ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
        use Encode qw(encode decode); That did the trick, thanks. Did my best to understand the docs but it's like a whole different language to me! :)