JavaScript Minifier Perl Example

Check the example on how to use
Perl
to minify a JavaScript 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/javascript-minifier/api/raw',
    [
        'Accept'         => '*/*',
        'User-Agent'     => 'curl/7.55.1',
        'Content-Type'   => 'application/x-www-form-urlencoded'
    ],
    "input=console.log(  1  )"
);
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:

console.log(1)