Mojolicious and Docker - DEV Community
This post plans to illustrate how you can build and dockerize and Mojolicious application and solve... Tagged with docker, perl, devops, mojolicious.
Day 23: One-Liners for Fun and Profit
Mojo one-liners are just Perl one-liners. You will use -E (or -e) to write the program. You might use -n to loop over input, or -p to do the same while printing $_ after each item, just like normal one-liners.
To get the extra Mojo goodness, add -Mojo. The name itself is a cute hack. Since -M is what loads a module on the command line, the module name is therefore ojo.
Perl Advent Calendar 2022 - Create Professional Slideshows with Mojolicious::Plugin::RevealJS
Santa's elf had a problem. He had to write a presentation very fast and show it to a bunch of new elves. The email assigning this to him was sent by Santa himself. The elf started to look on MetaCPAN and found this module: Mojolicious::Plugin::RevealJS
Input Validation and Errors — Swagg::Blogg
I used to use the flash() helper in Mojolicious for reporting errors back to the user but recently discovered I can just use Mojolicious:...
How much is that BLÅHAJ in the (terminal) window?—The Phoenix Trap
Using one line of Perl, you can grab the price and even a picture of IKEA’s iconic cuddly shark toy!
https://phoenixtrap.com/2022/04/12/how-much-is-that-blahaj-in-the-terminal-window/
$ perl -Mojo -E 'say g("https://sik.search.blue.cdtapps.com/us/en/search-result-page", form => {types => "PRODUCT", q => "BLÅHAJ"})->json->{searchResultPage}{products}{main}{items}[0]{product}->@{qw(currencyCode priceNumeral)}'
Migrating from LWP::UserAgent to Mojo::UserAgent : perl
I'm in the process of migrating my development process from the old comfortable tools I've been using for the last handful of years over to Mojo-based code whenever possible. I'd like to thank everyone in this subreddit that's helped me in on this journey of discovery in prior posts, and hope that I can continue to benefit from the wisdom of the collective.
Mojolicious lets you do a lot of things more concisely than some other frameworks/modules, too. This type of setup/flow is normally what I use in my client-side scripts:
my $ua = Mojo::UserAgent->new;
my $post_result = $ua->post(
$endpoint,
{ SOAPAction => $soapaction, 'Content-Type' => 'text/xml' }, # headers
$message # request body
)->result;
Debugging with Perl
Eugen Konkov — 45 minutes 🐪
Interactive debugging.
This talk about how to catch and report perl application exceptions.
An example based on Mojolicious web server will be given.
I will show how to reproduce exceptions and debug them.
The example will describe how to access and view data at any stack frame.
Also I will show how to implement new debugger commands and how to debug them (yeah, you understand right: how to debug perl debugger while debugging)
This talk will about my second proprietary debugger. It is full rewrite of first version: https://github.com/KES777/Devel-DebugHooks
Playwright and Mojolicious - DEV Community
It's Hack Week again at SUSE. 🥳 An annual tradition where we all work on passion projects for a whole... Tagged with mojolicious, perl, javascript, node.
Modern Perl CGI | Aristotle [blogs.perl.org]
A modernisation of this using Plack is straightforwardly equivalent:
#!/usr/bin/env perl
use strict;
use warnings;
use Plack::Request;
use Encode::Simple;
use JSON::MaybeXS;
my $app = sub {
my $req = Plack::Request->new($_[0]);
my $input = eval { decode 'UTF-8', $req->parameters->{'input'} };
[ 200, [ 'Content-Type', 'application/json; charset=UTF-8' ], [ encode_json { output => uc $input } ] ];
};
This is now a full PSGI app and as such gains all the same additional deployment options of the Mojolicious example. To deploy it as a CGI script you add this line at the bottom:
use Plack::Handler::CGI; Plack::Handler::CGI->new->run($app);
In all it takes about twice as long to load as the CGI.pm example, compared to the Mojolicious example taking about 7× as long. In exchange you get all the benefits of the PSGI ecosystem – without losing any of the strengths of deploying as a CGI script, unlike the Mojolicious example.
Perl Advent Calendar 2017 - Mojolicious on the Command Line
Mojolicious provides a utility class, ojo, that allows us to leverage the power of Mojolicious from the command line:
perl -Mojo -E 'say g("http://goo.gl/EsGk3b")->text'
The -M flag tells perl to load the following module, so -Mojo, despite looking like a super secret Mojo flag to perl actually is a cheeky way of saying use ojo.
ojo provides a whole host of single letter functions that are shortcuts to Mojolicious utilities, allowing you to quickly do things like fetching urls, reading and writing files, encoding and decoding json, manipulating data structures and a whole host more.