Name : perl-Data-Decrement
| |
Version : 0.002
| Vendor : obs://build_opensuse_org/devel:languages:perl
|
Release : lp156.1.1
| Date : 2024-07-03 19:03:56
|
Group : Development/Libraries/Perl
| Source RPM : perl-Data-Decrement-0.002-lp156.1.1.src.rpm
|
Size : 0.03 MB
| |
Packager : https://www_suse_com/
| |
Summary : Provide extra magic logic for auto-decrement
|
Description :
Perl\'s auto-increment operator (\'++\') has some convenience feature built in. Quoting perlop:
The auto-increment operator has a little extra builtin magic to it. If you increment a variable that is numeric, or that has ever been used in a numeric context, you get a normal increment. If, however, the variable has been used in only string contexts since it was set, and has a value that is not the empty string and matches the pattern \"/^[a-zA-Z]*[0-9]*\\z/\", the increment is done as a string, preserving each character within its range, with carry:
print ++($foo = \"99\"); # prints \"100\" print ++($foo = \"a0\"); # prints \"a1\" print ++($foo = \"Az\"); # prints \"Ba\" print ++($foo = \"zz\"); # prints \"aaa\"
\"undef\" is always treated as numeric, and in particular is changed to 0 before incrementing (so that a post-increment of an undef value will return 0 rather than \"undef\").
The auto-decrement operator is not magical.
This module provides the \'decr()\' function to do the decrement equivalent, although it is not exactly the reverse of the increment operation. In general, the rule is that \'decr(++$a)\' should return the same value as the original \'$a\' before the auto-increment, with a couple of exception.
* * Positive integers are decremented as string
Positive integers, including those with zero prefix, are decremented as string.
print decr(-123); # prints \"-124\", treated as number print decr(123); # prints \"122\", treated as string print decr(100); # prints \"099\", treated as string
\"undef\" like in auto-increment is treated as number 0.
print decr(undef); # prints \"-1\", treated as number
* * Decrementing is not done when leftmost digit is already \"A\", \"a\", or 0
When carrying over to the left-most digit, and the digit is already \"A\", \"a\", or \"0\", decrementing is not done. The original value is returned and a warning \"Cannot decrement \'< VALUE>\'\" is issued. Examples:
print decr(0); # prints \"0\", warns \"Cannot decrement \'0\'\" print decr(\"a1\"); # prints \"a0\" print decr(\"b0\"); # prints \"a9\" print decr(\"a0\"); # prints \"a0\", warns \"Cannot decrement \'a0\'\" print decr(\"bZz0\"); # prints \"bZy9\" print decr(\"bZa0\"); # prints \"bYz9\" print decr(\"bAa0\"); # prints \"aZz9\" print decr(\"aAa0\"); # prints \"aAa0\", warns \"Cannot decrement \'aAa0\'\"
|
RPM found in directory: /packages/linux-pbone/ftp5.gwdg.de/pub/opensuse/repositories/devel:/languages:/perl:/CPAN-D/15.6/noarch |