HTML Minifier Perl Example
Check the example on how to use
Perl
to minify a HTML hardcoded string and output to stdout:use LWP::UserAgent;
my $ua = LWP::UserAgent->new( 'send_te' => '0' );
my $r = HTTP::Request->new(
'POST' => 'https://www.toptal.com/developers/html-minifier/api/raw',
[
'Accept' => '*/*',
'User-Agent' => 'curl/7.55.1',
'Content-Type' => 'application/x-www-form-urlencoded'
],
"input=<input type="text" />"
);
my $minified = $ua->request( $r, )->decoded_content();
print $minified;Save the code to a file named
minify.pl
and run the following command:perl minify.pl
Output:
<input>