NAME

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

VERSION

This document describes version 0.06 of Getopt::Long::EvenLess (from Perl distribution Getopt-Long-EvenLess), released on 2016-12-02.

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. GLEL is equivalent to GL in this mode: bundling, no_ignore_case, no_getopt_compat, gnu_compat, permute.

  • 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     load_gl      run_gl load_gl_less run_gl_less run_gl_evenless load_gl_evenless   perl
load_gl           67.11+-0.72/s          --       -2.7%       -68.5%      -68.6%          -81.3%           -81.5% -87.9%
run_gl            68.97+-0.46/s   2.8+-1.3%          --       -67.6%      -67.7%          -80.8%           -81.0% -87.5%
load_gl_less       212.8+-1.7/s 217.2+-4.2% 208.6+-3.2%           --       -0.3%          -40.7%           -41.3% -61.5%
run_gl_less      213.49+-0.99/s 218.1+-3.7% 209.5+-2.5%   0.3+-0.92%          --          -40.5%           -41.2% -61.4%
run_gl_evenless    358.8+-2.4/s 434.7+-6.7% 420.2+-4.9%   68.6+-1.7%  68.1+-1.4%              --            -1.1% -35.1%
load_gl_evenless   362.9+-4.6/s 440.8+-8.9% 426.2+-7.5%   70.5+-2.5%    70+-2.3%       1.1+-1.4%               -- -34.4%
perl               553.1+-3.9/s    724+-11% 701.9+-7.8%  159.8+-2.8% 159.1+-2.2%      54.1+-1.5%       52.4+-2.2%     --

Average times:
  perl            :     1.8080ms
  load_gl_evenless:     2.7556ms
  run_gl_evenless :     2.7871ms
  run_gl_less     :     4.6841ms
  load_gl_less    :     4.6992ms
  run_gl          :    14.4991ms
  load_gl         :    14.9009ms

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.