|
|
Choosing A Webhost: |
completely rewind an HTML::TokeParser (PullParser): msg#00051lang.perl.modules.lwp
I want to parse out some HTML to count the text characters and then rewind to the beginning of the parser to step through tags and excerpt to an argument supplied character or percentage point in the *text* chars and then, keeping track of what tags are open, automatically add close tags. To be used in a TT2 filter like "truncate" but for HTML instead of plain text. So that... [% html = "<p><b>this <i>is something to truncate</i></b></p>" %] [% html | truncate_html(10) %] Would output <p><b>this <i>is so...</i></b></p> ^^^^^^12345^^^67890 Anyway, the trouble I'm trying to address is rewinding the parser for the second walkthrough once I've counted text characters. I want to do this: 1 while $p->unget_token() But it doesn't work because HTML::PullParser->unget_token returns the parser object itself. To make a long story short, and it's not too late for that -- would changing the return be reasonable or would it break code? sub unget_token { my $self = shift; unshift @{$self->{pullparser_accum}}, @_; # $self; <-- change, don't return $self anymore } If not, does anyone have a smart idea for how to rewind it while respecting the interface (ie, not testing $self->{pullparser_accum})? Thanks! -Ashley
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | RE: WWW::Mechanize, save images from a page, Dhanashri Bhate |
|---|---|
| Next by Date: | Re: completely rewind an HTML::TokeParser (PullParser), apv |
| Previous by Thread: | WWW::Mechanize, save images from a page, Dhanashri Bhate |
| Next by Thread: | Re: completely rewind an HTML::TokeParser (PullParser), apv |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |