NAME

Getopt::Long::EvenLess - Like Getopt::Long::Less, but with even less features

VERSION

This document describes version 0.05 of Getopt::Long::EvenLess (from Perl distribution Getopt-Long-EvenLess), released on 2016-10-29.

DESCRIPTION

EXPERIMENTAL WORK.

This module (GLEL for short) is a reimplementation of Getopt::Long (GL for short), but with much less features. It's an even more stripped down version of Getopt::Long::Less (GLL for short) and is perhaps less convenient to use for day-to-day scripting work.

The main goal is minimum amount of code and small startup overhead. This module is an experiment of how little code I can use to support the stuffs I usually do with GL.

Compared to GL and GLL, it:

  • does not have Configure()

    Nothing to configure, no different modes of operation.

  • does not support increment (foo+)

  • no type checking (foo=i, foo=f, foo=s all accept any string)

  • does not support optional value (foo:s), only no value (foo) or required value (foo=s)

  • does not support desttypes (foo=s@)

  • does not support handler other than coderef (so no "foo=s" => \$scalar, "foo=s" => \@ary, only "foo=s" => sub { ... })

    Also, in coderef handler, code will get a simple hash instead of a "callback" object as its first argument.

  • does not support hashref as first argument

  • does not support bool/negation (no foo!, so you have to declare both foo and no-foo manually)

The result?

Amount of code. GLEL is about 175 lines of code, while GL is about 1500. Sure, if you really want to be minimalistic, you can use this single line of code to get options:

@ARGV = grep { /^--([^=]+)(=(.*))?/ ? ($opts{$1} = $2 ? $3 : 1, 0) : 1 } @ARGV;

and you're already able to extract --flag or --opt=val from @ARGV but you also lose a lot of stuffs like autoabbreviation, --opt val syntax support syntax (which is more common, but requires you specify an option spec), custom handler, etc.

Startup overhead. Here's a sample startup overhead benchmark:

                           Rate        run_gl       load_gl   run_gl_less  load_gl_less run_gl_evenless load_gl_evenless   perl
run_gl            78.71+-0.21/s            --         -1.0%        -66.6%        -66.9%          -80.3%           -80.9% -87.3%
load_gl           79.55+-0.12/s   1.06+-0.31%            --        -66.2%        -66.6%          -80.1%           -80.7% -87.2%
run_gl_less      235.68+-0.28/s 199.41+-0.86% 196.28+-0.56%            --         -1.0%          -41.1%           -42.7% -62.1%
load_gl_less         238+-0.4/s 202.36+-0.95%  199.2+-0.67%   0.98+-0.21%            --          -40.6%           -42.2% -61.7%
run_gl_evenless    400.3+-1.9/s   408.6+-2.8%   403.3+-2.5%  69.87+-0.83%  68.21+-0.85%              --            -2.7% -35.6%
load_gl_evenless   411.7+-1.7/s     423+-2.5%   417.5+-2.2%  74.67+-0.73%  72.96+-0.76%     2.82+-0.64%               -- -33.8%
perl               621.4+-1.8/s   689.4+-3.1%   681.2+-2.6% 163.66+-0.84% 161.09+-0.89%    55.21+-0.87%     50.95+-0.75%     --

Average times:
  perl            :     1.6093ms
  load_gl_evenless:     2.4290ms
  run_gl_evenless :     2.4981ms
  load_gl_less    :     4.2017ms
  run_gl_less     :     4.2430ms
  load_gl         :    12.5707ms
  run_gl          :    12.7049ms

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/Getopt-Long-EvenLess.

SOURCE

Source repository is at https://github.com/perlancar/perl-Getopt-Long-EvenLess.

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Getopt-Long-EvenLess

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

SEE ALSO

Getopt::Long

Getopt::Long::Less

AUTHOR

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2016 by perlancar@cpan.org.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.