The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

scriptx-eg-getopt-specless - Parse command-line options using simple heuristics (demos debugging by dumping stash)

VERSION

This document describes version 0.000004 of scriptx-eg-getopt-specless (from Perl distribution ScriptX), released on 2020-10-01.

SYNOPSIS

% script-eg-getopt-specless
Please specify --name!

% script-eg-getopt-specless --name=Budi
Please specify --gender!

% script-eg-getopt-specless --name=Budi --gender=x
Invalid value in --gender, please specify m|f!

% script-eg-getopt-specless --name=Budi --gender=m
Hello, Mr. Budi!

% script-eg-getopt-specless --name=Budi --gender=m --foo
Hello, Mr. Budi!

DESCRIPTION

This script demonstrates the use of ScriptX::Getopt::Specless.

When you encounter a problem, e.g.:

% script-eg-getopt-specless --name=Budi --gender m
Invalid value in --gender, please specify m|f!

you can use the ScriptX::Debug::DumpStash:

% SCRIPTX_IMPORT=-Debug::DumpStash script-eg-getopt-specless --name=Budi --gender m
{
  argv  => ["f"],                           # {0}
  event => "before_run",                    # {1}
  opts  => { gender => 1, name => "Budi" }, # {2}
}
Invalid value in --gender, please specify m|f!

You notice that the gender option gets the value of 1 while f is parsed as an argument. That's because in specless option parsing, all option with value must be specified as --opt=val and not <--opt val>.

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/ScriptX.

SOURCE

Source repository is at https://github.com/perlancar/perl-ScriptX.

BUGS

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

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.

AUTHOR

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2020 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.