On 10/12/07, Patrik Hasibuan <[EMAIL PROTECTED]> wrote:

> Please tell me my mistake.

I'll catch enough to give you something to do, and leave the rest for
you and others to find. :-)

> use HTML::Parser;

It looks as if you're not subclassing HTML::Parser. Isn't that
obligatory? Jenda already gave you good advice:

    You should reread the HTML::Parser's docs and try to parse a
    simple, short static HTML

Once you can get a parser working on static text, then you can easily
convert it to work with LWP.

> my @result='';
> my @judul='';
> my @bodi='';

When a scalar value (such as a string) is used in a list context, the
scalar is silently promoted to a one-element list. That means that
these three arrays each contain one item, and that item is an empty
string. It's as if you had written this:

  my @result = my @judul = my @bodi = ('');

Is that your intention? If you want an array to start out empty, your
wish has been granted; every new array in Perl starts out empty by
default:

  my(@result, @judul, @bodi);  # all start out empty

> my $retrieveresult = $ua->request($req);
>
> my $p=HTML::Parser->new(text_h=>[\&text,'dtext']);
> $p->parse($retrieveresult);

I don't think that $retrieveresult is what you think. As I read the
docs, "The return value is a response object," not the parsable
response text. (It seems Jenda tried to tell you about that, too.
Shame on you for not reading more carefully.)

    http://search.cpan.org/~gaas/libwww-perl-5.808/lib/LWP/UserAgent.pm

Check that you're using these modules according to their
documentation. But if you're still having troubles, you could use the
debugger to see what's really happening. The easiest way to do that in
this kind of program is by putting a line like this one at an
interesting point in your algorithm:

  $DB::signal = 1 if defined $fred and $fred > $barney;

When the condition triggers (if, of course, you choose to use a
condition), if your program is running under the debugger, it will
halt before the next statement. You could use this technique to debug
your subroutine &text, for example. (I don't think it's parameters are
what you expect.)

Good luck with it!

--Tom Phoenix
Stonehenge Perl Training

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to