File-SharedVar

 view release on metacpan or  search on metacpan

lib/File/SharedVar.pm  view on Meta::CPAN

159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
=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 )