| Tree-Persist documentation | Contained in the Tree-Persist distribution. |
Tree::Persist::File - the base class for File plugins for Tree persistence
This class is a base class for the Tree::Persist::File::* hierarchy, which provides File plugins for Tree persistence.
In addition to any parameters required by its parent Tree::Persist::Base, the following parameters are required by connect():
For any File::* plugin to be used, the type must be 'File' (case-sensitive).
This is the filename that will be used as the datastore.
Please see the relevant section of Tree::Persist.
Please see the relevant section of Tree::Persist.
Rob Kinyon <rob.kinyon@iinteractive.com>
Stevan Little <stevan.little@iinteractive.com>
Thanks to Infinity Interactive for generously donating our time.
Copyright 2004, 2005 by Infinity Interactive, Inc.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Tree-Persist documentation | Contained in the Tree-Persist distribution. |
package Tree::Persist::File; use strict; use warnings; use base qw( Tree::Persist::Base ); use Scalar::Util qw( blessed ); our $VERSION = '1.00'; sub _init { my $class = shift; my ($opts) = @_; my $self = $class->SUPER::_init( $opts ); $self->{_filename} = $opts->{filename}; return $self; } sub _create { my $self = shift; open my $fh, '>', $self->{_filename} or die "Cannot open '$self->{_filename}' for writing: $!\n"; print $fh $self->_build_string( $self->{_tree} ); close $fh; return $self; } *_commit = \&_create; 1; __END__