Package Info

perl-Data-OptList


Parse and validate simple name/value option pairs


Unspecified

Hashes are great for storing named data, but if you want more than one entry for a name, you have to use a list of pairs. Even then, this is really boring to write:

$values = [ foo => undef, bar => undef, baz => undef, xyz => { ... }, ];

Just look at all those undefs! Don't worry, we can get rid of those:

$values = [ map { $_ => undef } qw(foo bar baz), xyz => { ... }, ];

Aaaauuugh! We've saved a little typing, but now it requires thought to read, and thinking is even worse than typing... and it's got a bug! It looked right, didn't it? Well, the 'xyz => { ... }' gets consumed by the map, and we don't get the data we wanted.

With Data::OptList, you can do this instead:

$values = Data::OptList::mkopt([ qw(foo bar baz), xyz => { ... }, ]);

This works by assuming that any defined scalar is a name and any reference following a name is its value.


License: Artistic-1.0 OR GPL-1.0-or-later
URL: https://metacpan.org/release/Data-OptList

Categories

Releases

Package Version Update ID Released Package Hub Version Platforms Subpackages
0.113-bp155.1.5 info GA Release 2023-05-17 15 SP5
  • AArch64
  • ppc64le
  • s390x
  • x86-64
  • perl-Data-OptList
0.112-bp154.1.78 info GA Release 2022-05-09 15 SP4
  • AArch64
  • ppc64le
  • s390x
  • x86-64
  • perl-Data-OptList
0.110-bp153.1.32 info GA Release 2021-03-05 15 SP3
  • AArch64
  • ppc64le
  • s390x
  • x86-64
  • perl-Data-OptList
0.110-bp152.3.21 info GA Release 2020-04-16 15 SP2
  • AArch64
  • ppc64le
  • s390x
  • x86-64
  • perl-Data-OptList
0.110-bp151.3.1 info GA Release 2019-07-16 15 SP1
  • AArch64
  • ppc64le
  • s390x
  • x86-64
  • perl-Data-OptList
0.110-bp151.2.15 info GA Release 2019-05-18 15 SP1
  • AArch64
  • ppc64le
  • s390x
  • x86-64
  • perl-Data-OptList
0.110-bp150.2.4 info GA Release 2018-07-30 15
  • AArch64
  • ppc64le
  • s390x
  • x86-64
  • perl-Data-OptList