String::Incremental - incremental string with your rule
use String::Incremental; my $str = String::Incremental->new( format => 'foo-%2=-%=', orders => [ [0..2], 'abcd', ], ); # or use String::Incremental qw( incremental_string ); my $str = incremental_string( 'foo-%2=-%=', [0..2], 'abcd', ); print "$str"; # prints 'foo-00-a' $str++; $str++; $str++; print "$str"; # prints 'foo-00-d' $str++; print "$str"; # prints 'foo-01-a' $str->set( 'foo-22-d' ); print "$str"; # prints 'foo-22-d'; $str++; # dies, cannot ++ any more
String::Incremental provides generating string that can increment in accordance with your format and rule.
format: Str
orders: ArrayRef
returns "current" string.
following two variables are equivalent:
my $a = $str->as_string(); my $b = "$str";
sets to $val.
tying with String::Incremental, assignment syntax is available as synonym of this method:
tie my $str, 'String::Incremental', ( format => 'foo-%2=-%=', orders => [ [0..2], 'abcd' ], ); $str = 'foo-22-d'; # same as `$str->set( 'foo-22-d' )` print "$str"; # prints 'foo-22-d';
increases positional state of order and returns its character.
following two operation are equivalent:
$str->increment(); $str++;
decreases positional state of order and returns its character.
$str->decrement(); $str--;
another way to construct String::Incremental instance.
this function is not exported automatically, you need to export manually:
use String::Incremental qw( incremental_string );
Copyright (C) issm.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
issm <issmxx@gmail.com>
To install String::Incremental, copy and paste the appropriate command in to your terminal.
cpanm
cpanm String::Incremental
CPAN shell
perl -MCPAN -e shell install String::Incremental
For more information on module installation, please visit the detailed CPAN module installation guide.