NAME
String::UpdateYears - Look for year or years range in string and update years
SYNOPSIS
my
$updated_or_undef
= update_years(
$string_with_year
,
$opts_hr
,
$new_last_year
);
SUBROUTINES
update_years
my
$updated_or_undef
= update_years(
$string_with_year
,
$opts_hr
,
$new_last_year
);
Look for year or years range in string and update them.
Parameters:
C<
$string_with_year
> - Input string
with
year or range years.
C<
$opts_hr
> - Reference to hash
with
options. Possible options:
C<prefix_glob> - Prefix
glob
from begin of string to year(s) part (
default
'.*'
).
C<postfix_glob> - Postfix
glob
from year(s) part to end of string (
default
'.*'
).
C<
$new_last_year
> - New
last
year to update.
Returns undef if year or years range not found in string. Returns updated string if year or years range found in string.
EXAMPLE1
EXAMPLE2
use
strict;
use
warnings;
my
$input
= decode_utf8(
'© 1977-2022 Michal Josef Špaček'
);
my
$output
= update_years(
$input
, {}, 2023);
# Print input and output.
'Input: '
.encode_utf8(
$input
).
"\n"
;
'Output: '
.encode_utf8(
$output
).
"\n"
;
# Output:
# Input: © 1987-2022 Michal Josef Špaček
# Output: © 1987-2023 Michal Josef Špaček
SEE ALSO
- perl-module-copyright-years
-
Tool for update copyright years in Perl distribution.
- Pod::CopyrightYears
-
Object for copyright years changing in POD.
DEPENDENCIES
REPOSITORY
https://github.com/michal-josef-spacek/String-UpdateYears
AUTHOR
Michal Josef Špaček mailto:skim@cpan.org
LICENSE AND COPYRIGHT
© 2023 Michal Josef Špaček
BSD 2-Clause License
VERSION
0.01