File-SharedVar
view release on metacpan or search on metacpan
lib/File/SharedVar.pm view on Meta::CPAN
159160161162163164165166167168169170171172173174175176177178179=item *
C<$increment>: If true (non-zero), increments the existing value by C<$value>; otherwise, sets the key to C<$value>.
=back
Returns the previous value associated with the key, from before the update.
=cut
sub
update {
my
(
$self
,
$key
,
$val
,
$inc
) =
@_
;
my
(
$data
)= _load_from_file(
$self
,1);
my
$ret
=
$data
->{
$key
};
# Update the value for the key
if
(
$inc
) {
$data
->{
$key
} = (
$data
->{
$key
} // 0) +
$val
;
}
else
{
$data
->{
$key
} =
$val
;
}
( run in 0.481 second using v1.01-cache-2.11-cpan-49f99fa48dc )