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

String::Incremental::Char

SYNOPSIS

use String::Incremental::Char;

my $ch = String::Incremental::Char->new( order => 'abcd' );

print "$ch";  # -> 'a';

$ch++; $ch++; $ch++;
print "$ch";  # -> 'd';

$ch++;  # dies

my $ch1 = String::Incremental::Char->new( order => ['a'..'c'] );
my $ch2 = String::Incremental::Char->new( order => ['x'..'z'], upper => $ch1 );

print "${ch1}${ch2}";  # -> ax

$ch2++; $ch2++;
print "${ch1}${ch2}";  # -> az

$ch2++;
print "${ch1}${ch2}";  # -> bx

$ch1++;
print "${ch1}${ch2}";  # -> cx

...

print "${ch1}${ch2}";  # -> cz
$ch2++;  # dies

DESCRIPTION

String::Incremental::Char is ...

CONSTRUCTORS

new( %args ) : String::Incremental::Char

%args:

order : Str|ArrayRef

incrementation rule

upper : String::Incremental::Char

upper-digit char as String::Incremental::Char instance

METHODS

as_string() : Str

returns "current" character.

following two variables are equivalent:

my $a = $ch->as_string();
my $b = "$ch";
set( $val, \%opts ) : String::Incremental::Char

sets "current" state as $val.

if $opts->{test} is true, "current" state is not update, only returns or dies.

increment() : Str

increases position of order and returns its character.

following two operation are equivalent:

$ch->increment();
$ch++;
decrement() : Str

decreases position of order and returns its character.

following two operation are equivalent:

$ch->decrement();
$ch--;

LICENSE

Copyright (C) issm.

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

AUTHOR

issm <issmxx@gmail.com>