Created
September 18, 2016 10:38
-
-
Save chankeypathak/dd5d7f25a63e1ed8d02328cea6adef39 to your computer and use it in GitHub Desktop.
HTML::TokeParser::Simple Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use utf8; | |
use strict; | |
use warnings; | |
use open qw[ :std :encoding(UTF-8) ]; | |
use HTML::TokeParser::Simple; | |
run(\@ARGV); | |
sub run { | |
my $argv = shift; | |
my $parser = HTML::TokeParser::Simple->new(handle => \*DATA); | |
while (my $token = $parser->get_token) { | |
print $token->as_is; | |
if ($token->is_start_tag('form')) { | |
print qq{\n<input type="hidden" name="sid" value="<TMPL_VAR NAME=SID>">\n}; | |
} | |
} | |
} | |
__DATA__ | |
<h3>Here is a form:</h3> | |
<form | |
method="POST" | |
action="https://example.com/action-action-action.pl" | |
id="action" | |
name="actionable_form"> | |
<label for="date">Date:</label> | |
<input type="date" name="date" id="date"> | |
<input type="submit"> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment