File Coverage

blib/lib/Acme/CPANModules/OneLinerTools.pm
Criterion Covered Total %
statement 3 3 100.0
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 4 4 100.0


line stmt bran cond sub pod time code
1             package Acme::CPANModules::OneLinerTools;
2              
3 1     1   425248 use strict;
  1         3  
  1         342  
4              
5             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
6             our $DATE = '2024-06-21'; # DATE
7             our $DIST = 'Acme-CPANModules-OneLinerTools'; # DIST
8             our $VERSION = '0.005'; # VERSION
9              
10             our $LIST = {
11             summary => 'List of modules to make your life easier when writing perl one-liners',
12             description => <<'MARKDOWN',
13              
14             This list also tries to catalog modules that are meant to be primarily used in
15             one-liners.
16              
17             MARKDOWN
18             entries => [
19              
20             {
21             module => 'L',
22             description => <<'MARKDOWN',
23              
24             One of the "module autoloader" modules, which happens to have a short name for
25             one-liner usage. So instead of having to type this:
26              
27             % perl -MOrg::Parser::Tiny -E'$doc = Org::Parser::Tiny->new->parse_file("/home/budi/todo.org"); ...'
28              
29             you can now write:
30              
31             % perl -ML -E'$doc = Org::Parser::Tiny->new->parse_file("/home/budi/todo.org"); ...'
32              
33             "Module autoloader" modules work using Perl's autoloading mechanism (read
34             `perlsub` for more details). By declaring a subroutine named `AUTOLOAD` in the
35             `UNIVERSAL` package, you setup a fallback mechanism when you call an undefined
36             subroutine. 's AUTOLOADER loads the module using then
37             try to invoke the undefined subroutine once again.
38              
39             MARKDOWN
40             tags => ['module-loading'],
41             },
42              
43             {
44             module => 'lib::xi',
45             description => <<'MARKDOWN',
46              
47             This module can automatically install missing module during run-time using
48             `cpanm`. Convenient when running a Perl script (that comes without a proper
49             distribution or `cpanfile`) that uses several modules which you might not have.
50             The alternative to lib::xi is the "trial and error" method: repeatedly run the
51             Perl script to see which module it tries and fails to load.
52              
53             lib::xi works by installing a hook in `@INC`.
54              
55             MARKDOWN
56             tags => ['module-loading'],
57             alternate_modules => [
58             'Require::Hook::More', # the autoinstalling feature has not been implemented though
59             ],
60             },
61              
62             {
63             module => 'Log::ger::App',
64             description => <<'MARKDOWN',
65              
66             A convenient way to display (consume) logs if your application uses
67             to produce logs.
68              
69             MARKDOWN
70             tags => ['logging'],
71             },
72              
73             {
74             module => 'DD::Dummy',
75             description => <<'MARKDOWN',
76              
77             My preference when dumping data structure when debugging Perl application is,
78             well, Perl format (unlike some others which prefer custom format like
79             ). The DD-Dummy distribution provides module, which in
80             turn exports `dd` to dump your data structures for debugging using
81             . Another good alternative is which by default uses YAML
82             output but can be changed with this environment variable setting:
83              
84             PERL_XXX_DUMPER=Data::Dump
85              
86             MARKDOWN
87             alternate_modules => ['XXX', 'Data::Printer'],
88             tags => ['debugging'],
89             },
90              
91             {
92             module => 'Devel::Confess',
93             description => <<'MARKDOWN',
94              
95             Forces stack trace when your application warns or dies. Used with the perl's
96             `-d` flag:
97              
98             % perl -d:Confess ...
99             % perl -d:Confess=dump ...
100              
101             MARKDOWN
102             tags => ['debugging'],
103             },
104              
105             {
106             module => 'Carp::Patch::Config',
107             description => <<'MARKDOWN',
108              
109             is used as a stack trace printer (also indirectly if you use
110             ). Sometimes you want to customize some Carp parameters like
111             $Carp::MaxArgNums and $Carp::MaxArgLen from the command-line, and this is where
112             this module helps.
113              
114             MARKDOWN
115             tags => ['debugging'],
116             },
117              
118             {
119             module => 'DBIx::Conn::MySQL',
120             description => <<'MARKDOWN',
121              
122             Shortcut when connecting to MySQL database in your one-liner. Instead of:
123              
124             % perl -MDBI -E'my $dbh = DBI->connect("dbi:mysql:database=mydb", "someuser", "somepass"); $dbh->selectrow_array("query"); ...'
125              
126             you can type:
127              
128             % perl -MDBIx::Conn::MySQL=mydb -E'$dbh->selectrow_array("query"); ...'
129              
130             MARKDOWN
131             tags => ['database', 'dbi'],
132             },
133              
134             {
135             module => 'DBIx::Conn::SQLite',
136             description => <<'MARKDOWN',
137              
138             Shortcut when connecting to MySQL database in your one-liner. Instead of:
139              
140             % perl -MDBI -E'my $dbh = DBI->connect("dbi:SQLite:dbname=mydb", "", ""); $dbh->selectrow_array("query"); ...'
141              
142             you can type:
143              
144             % perl -MDBIx::Conn::SQLite=mydb -E'$dbh->selectrow_array("query"); ...'
145              
146             MARKDOWN
147             tags => ['database', 'dbi'],
148             },
149              
150             {module=>'ojo'},
151             {module=>'DDP', summary=>'From the Data::Printer distribution', tags=>['debugging']},
152             {module=>'XXX', tags=>['debugging']},
153             {module=>'eval', tags=>['debugging']},
154             {module=>'this_mod', tags=>['module-loading']},
155             {module=>'lib::filter', tags=>['debugging', 'module-loading']},
156             ],
157             };
158              
159             1;
160             # ABSTRACT: List of modules to make your life easier when writing perl one-liners
161              
162             __END__