Acme-CPANModulesBundle-Import-MojoliciousAdvent-2017
view release on metacpan or search on metacpan
"x_mentions" : {
"x_mentions" : {
"App::ModuleBuildTiny" : "0",
"App::cpanminus" : "0",
"App::opan" : "0",
"Benchmark" : "0",
"Class::Method::Modifiers" : "0",
"DBI" : "0",
"DBIx::Class" : "0",
"DBM::Deep" : "0",
"Data::Dumper" : "0",
"Dist::Zilla" : "0",
"Dist::Zilla::Plugin::ShareDir" : "0",
"ExtUtils::MakeMaker" : "0",
"File::Share" : "0",
"File::ShareDir" : "0",
"File::ShareDir::Install" : "0",
"FindBin" : "0",
"Galileo" : "0",
"GraphQL" : "0",
"IO::Socket::SSL" : "0",
devdata/https_mojolicious.io_blog_2017_12_23_day-23-one-liners-for-fun-and-profit view on Meta::CPAN
The names of these functions are (almost) all just one letter long: these are one-liners after all, brevity is key!
I'll show you them below.</p>
<p>Importantly, however, the main namepace also imports <a href="http://mojolicious.org/perldoc/Mojolicious/Lite">Mojolicious::Lite</a>.
Whether you use it or not, you have a Lite app just waiting for you!
One caveat is that this does import <code>strict</code>, so you must declare your variables unless you disable strict manually.</p>
<h3>Output and Input</h3>
<p>The first two functions we will look at are related to output.
The function <code>r</code> takes an argument and formats it with <a href="http://mojolicious.org/perldoc/Mojo/Util#dumper">Mojo::Util's wrapper</a> for <a href="https://metacpan.org/pod/Data::Dumper">Data::Dumper</a>.
Somewhat similarly the <code>j</code> function takes any Perl data structure and <a href="http://mojolicious.org/perldoc/Mojo/JSON#encode_json">return it as a JSON string</a>.</p>
<pre><code>perl -Mojo -E 'print r({hello => "world"})'
perl -Mojo -E 'print j({hello => "world"})'
</code></pre>
<p>The <code>j</code> function is more interesting in that if you give it a string, it will <a href="http://mojolicious.org/perldoc/Mojo/JSON#decode_json">decode it from JSON</a> and return a data structure.</p>
<pre><code>echo '{"hello":"world"}' | perl -Mojo -E 'print j(<>)->{hello}'
</code></pre>
devdata/https_mojolicious.io_blog_2017_12_23_day-23-one-liners-for-fun-and-profit view on Meta::CPAN
<pre><code>29.3775 wallclock secs (29.11 usr + 0.26 sys = 29.37 CPU) @ 0.34/s (n=10)
</code></pre>
<p>Knowing that data taken with and without proposed changes we can have a better idea of the performance gains or impacts from that change.
While there is no magic in this function, the ease-of-use of the benchmarker means we are actually likely to use it, even for what may seem like small and insignificant changes.
This is a major reason for Mojolicious' consistently blazing speeds.</p>
<h2>Conclusion</h2>
<p>Making <code>ojo</code> one-liners can be great to experiment with new concepts, demonstrate problems, fetch and work with data, and many other tasks.
You might use them in non-web one-liners that need JSON or Data::Dumper or perhaps MMojo::Collection for chaining.
(Speaking of chaining, for bonus points, check out <a href="https://metacpan.org/pod/ojoBox">ojoBox</a> for <a href="https://metacpan.org/pod/Mojo::Autobox">autoboxing Perl types</a>, making even cooler chains!)</p>
<p>These one-liners are not going to be everyone's cup of tea.
If these don't seem like your's you can completely ignore them.</p>
<p>However, once you start using them, I think you'll find yourself using them often.</p>
</section>
<small><p><a href="https://commons.wikimedia.org/w/index.php?curid=21375125">Image</a> by é <a href="http://www.royan.com.ar" rel="nofollow">Jorge Royan</a>, <a href="https://creativecommons.org/licenses/by-sa/3.0" title="Creative Co...
</small>
lib/Acme/CPANModules/Import/MojoliciousAdvent/2017.pm view on Meta::CPAN
package Acme::CPANModules::Import::MojoliciousAdvent::2017;
our $DATE = '2018-12-30'; # DATE
our $VERSION = '0.001'; # VERSION
our $LIST = {description=>"This list is generated by extracting module names mentioned in [https://mojolicious.io/page/advent/2017/] (retrieved on 2018-12-30). Visit the URL for the full contents.",entries=>[{module=>"App::cpanminus"},{module=>"Mojo:...
1;
# ABSTRACT: Modules mentioned in Mojolicious Advent Calendar 2017
__END__
=pod
=encoding UTF-8
lib/Acme/CPANModules/Import/MojoliciousAdvent/2017.pm view on Meta::CPAN
=item * L<JSON::Validator>
=item * L<Mojolicious::Plugin::OpenAPI>
=item * L<Mojolicious::Routes::Route>
=item * L<OpenAPI::Client>
=item * L<Benchmark>
=item * L<Data::Dumper>
=item * L<Mojo::Autobox>
=item * L<Mojo::ByteStream>
=item * L<Mojo::Util>
=item * L<ojo>
=item * L<ojoBox>
lib/Acme/CPANModules/Import/MojoliciousAdvent/2017_12_23.pm view on Meta::CPAN
package Acme::CPANModules::Import::MojoliciousAdvent::2017_12_23;
our $DATE = '2018-12-30'; # DATE
our $VERSION = '0.001'; # VERSION
our $LIST = {description=>"This list is generated by extracting module names mentioned in [https://mojolicious.io/blog/2017/12/23/day-23-one-liners-for-fun-and-profit] (retrieved on 2018-12-30). Visit the URL for the full contents.",entries=>[{module...
1;
# ABSTRACT: Modules mentioned in Mojolicious Advent Calendar 2017 (day 23)
__END__
=pod
=encoding UTF-8
lib/Acme/CPANModules/Import/MojoliciousAdvent/2017_12_23.pm view on Meta::CPAN
Modules mentioned in Mojolicious Advent Calendar 2017 (day 23).
This list is generated by extracting module names mentioned in [https://mojolicious.io/blog/2017/12/23/day-23-one-liners-for-fun-and-profit] (retrieved on 2018-12-30). Visit the URL for the full contents.
=head1 INCLUDED MODULES
=over
=item * L<Benchmark>
=item * L<Data::Dumper>
=item * L<Mojo::Autobox>
=item * L<Mojo::ByteStream>
=item * L<Mojo::Collection>
=item * L<Mojo::DOM>
=item * L<Mojo::File>
( run in 0.476 second using v1.01-cache-2.11-cpan-a5abf4f5562 )