hi

2002-03-01 Thread kavitha malar

what is the use of timeout in Finance::Quote module .
Anybody can  explain .

--jude



RFC:: New HTML::TokeParser Interface

2002-03-01 Thread Curtis Poe

After prompting from some people on Perlmonks who thought I should consider
this for the CPAN, I finally got off my duff and rewrote the interface for
HTML::TokeParser::Easy.  Re: some comments on the libwww mailing list:

 Gisle Aas [EMAIL PROTECTED] wrote (2002-02-01)a:
 I think blessing of the tokens might have merit.  I also think that
 HTML::TokeParser (and HTML::PullParser) should have some kind of
 support for this.

 Could for instance be provided by an interface like:

 my $p = HTML::PullParser-new(file = index.html,
   start = event, tagname, @attr,
   end   = event, tagname,
   token_class = MyToken,
  );

 where the array returned by $p-get_token would be blessed if the
 'token_class' attribute was set up.

That was in regard to my speculation as to whether or not the TokeParser
interface could be further cleaned up by blessing the returned tokens and
calling methods on them.  I went ahead and did this.  The get_token() and
get_tag() methods have been overridden.  Here's how to print the comments in
an HTML doc:

   my $p = HTML::TokeParser::Easy-new( $doc );
   while ( my $token = $p-get_token )
   {
   next if ! $token-is_comment;
   print $token-return_text, \n;
   }

I've also overloaded the is_/(start|end)/_tag methods to accept an optional
argument.  Now, instead of checking if you have the right tag type and then
checking to see if you have the right tag, you can just do:

$token-is_start_tag( 'form' )

instead of

$token-[0] eq 'S' and $token-[1] eq 'form'

Naturally, see the POD for full details and sample programs.

Gisle also mentioned the possibility of having HTML::Parser support the
blessed tokens, but I'm not sure exactly what will happen there, so I went
ahead and finished this.  The distribution can be downloaded at:

http://www.easystreet.com/~ovid/cgi_course/downloads/HTML-TokeParser-Easy-1.
1.tar.gz

I haven't yet written tests for it, but I promise not to upload to the CPAN
unless I do (the irony is, here at work, I've pushed hard to get the company
to use XP, which is a 'test first' methodology).

If you use HTML::TokeParser, I'd be much ecstatic if you could try this
module and let me know how (if) it works for you.  Also, if anyone can think
of a cleaner way to accomplish what I did internally, I'd be interested in
hearing that.

Cheers,
Curtis Ovid Poe
--
Ovid on http://www.perlmonks.org/
Someone asked me how to count to 10 in Perl:
push@A,$_ for reverse q.e...q.n.;for(@A){$_=unpack(q|c|,$_);@a=split//;
shift@a;shift@a if $a[$[]eq$[;$_=join q||,@a};print $_,$/for reverse @A