/usr/share/perl5/Data/Serializer/Persistent.pm is in libdata-serializer-perl 0.60-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | package Data::Serializer::Persistent;
use warnings;
use strict;
use vars qw($VERSION @ISA);
use IO::File;
use Carp;
$VERSION = '0.01';
sub _store {
my $self = (shift);
my $data = (shift);
my $file_or_fh = (shift);
if (ref($file_or_fh)) {
#it is a file handle so print straight to it
print $file_or_fh $self->{parent}->serialize($data), "\n";
#We didn't open the filehandle, so we shouldn't close it.
} else {
#it is a file, so open it
my ($mode,$perm) = @_;
unless (defined $mode) {
$mode = O_CREAT|O_WRONLY;
}
unless (defined $perm) {
$perm = 0600;
}
my $fh = new IO::File;
$fh->open($file_or_fh, $mode,$perm) || croak "Cannot write to $file_or_fh: $!";
print $fh $self->{parent}->serialize($data), "\n";
$fh->close();
}
}
sub _retrieve {
my $self = (shift);
my $file_or_fh = (shift);
if (ref($file_or_fh)) {
#it is a file handle so read straight from it
my $input = join('', <$file_or_fh>);
chomp($input);
return $self->{parent}->deserialize($input);
#We didn't open the filehandle, so we shouldn't close it.
} else {
my $fh = new IO::File;
$fh->open($file_or_fh, O_RDONLY) || croak "Cannot read from $file_or_fh: $!";
my $input = join('', <$fh>);
chomp($input);
$fh->close;
return $self->{parent}->deserialize($input);
}
}
1;
__END__
=pod
=head1 NAME
Data::Serializer::Persistent - Provide means of persistently storing serialized data in a file
=head1 SYNOPSIS
use Data::Serializer::Persistent
=head1 DESCRIPTION
Used internally to L<Data::Serializer(3)>, does not currently have any public methods
=head1 EXAMPLES
=over 4
=item Please see L<Data::Serializer::Cookbook(3)>
=back
=head1 METHODS
=head1 AUTHOR
Neil Neely <F<neil@neely.cx>>.
http://neil-neely.blogspot.com/
=head1 BUGS
Please report all bugs here:
http://rt.cpan.org/Public/Dist/Display.html?Name=Data-Serializer
=head1 COPYRIGHT AND LICENSE
Copyright (c) 2011 Neil Neely. All rights reserved.
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.2 or,
at your option, any later version of Perl 5 you may have available.
See http://www.perl.com/language/misc/Artistic.html
=head1 SEE ALSO
perl(1), Data::Serializer(3), IO::File(3).
=cut
|