Skip to content

Instantly share code, notes, and snippets.

@chankeypathak
Created September 18, 2016 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chankeypathak/dd5d7f25a63e1ed8d02328cea6adef39 to your computer and use it in GitHub Desktop.
Save chankeypathak/dd5d7f25a63e1ed8d02328cea6adef39 to your computer and use it in GitHub Desktop.
HTML::TokeParser::Simple Example
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