| 1 | package WWW::CheckPad::Parser; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | use HTML::Parser; | ||
| 6 | use base qw(HTML::Parser); | ||
| 7 | |||
| 8 | sub new { | ||
| 9 | my $class = shift; | ||
| 10 | my $self = new HTML::Parser(); | ||
| 11 | return bless $self, $class; | ||
| 12 | } | ||
| 13 | |||
| 14 | |||
| 15 | sub convert_to_item { | ||
| 16 | my ($self, $content, @args) = @_; | ||
| 17 | return $self->_parse($content, @args); | ||
| 18 | } | ||
| 19 | |||
| 20 | |||
| 21 | ############################################################ | ||
| 22 | # Usage: YourParser->param(<key>[, <value>]) | ||
| 23 | # Returns: The value related to <key>. | ||
| 24 | # | ||
| 25 | # If you need to save any values during parsing the string. | ||
| 26 | # You can use this method to save it. | ||
| 27 | ############################################################ | ||
| 28 | sub param { | ||
| 29 | my ($self, $key, $value) = @_; | ||
| 30 | |||
| 31 | $self->{_CP_PARSER} = {} if not defined $self->{_CP_PARSER}; | ||
| 32 | $self->{_CP_PARSER}->{$key} = $value if defined $value; | ||
| 33 | |||
| 34 | return $self->{_CP_PARSER}->{$key}; | ||
| 35 | } | ||
| 36 | |||
| 37 | |||
| 38 | 1; |