HTML::FormParser - Do things with the contents of HTML forms.
use HTML::FormParser; $p = HTML::FormParser->new(); $p->parse($html, form => sub { ... }, input => sub { ... });
An object-oriented module inheriting from HTML::Parser. HTML::FormParser takes a string containing HTML text and parses it, looking for forms.
Since this package inherits from HTML::Parser, only the API unique to HTML::FormParser is described.
Each type of tag that might be found in a form can have three kinds of action associated with it via callbacks. Callbacks are passed to the parse() method, and take up to three forms.
o start_${tagname} Called whenever $tagname is opened. o ${tagname} Called immediately after start_${tagname}, and immediately before end_${tagname}. o end_${tagname} Called whenever a closing $tagname is encountered.
Each of these callbacks will be passed the attributes and original tag text as parameters, when called.
use HTML::FormParser; $p = HTML::FormParser->new(); $p->parse($html, start_form => sub { my ($attr, $origtext) = @_; print "Form action is $attr->{action}\n"; });
Called whenever a particular start tag has been recognised. This module recognises these tags: <form>, <input>, <textarea> & <select>.
This method will be called by the parser and is not intended to be called from an application.
Called whenever a particular end tag is encountered.
This method is all you really need to do. Call it with callbacks for each tag type. These will be executed as described above.
Nothing.
o $p->parse() should ideally accept different forms for the html parameter, for example it should read from a stream or filehandle.
Simon Drabble <sdrabble@cpan.org> (C) 2002 Simon Drabble
This software is released under the same terms as perl.
To install HTML::FormParser, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTML::FormParser
CPAN shell
perl -MCPAN -e shell install HTML::FormParser
For more information on module installation, please visit the detailed CPAN module installation guide.