Connector::Builtin::File::Path
Highly configurable file writer/reader.
The base directory where the files are located. This parameter is mandatory.
Pattern for Template Toolkit to build the filename. The path components are available in the key ARGS. In set mode the unfiltered data is available in key DATA.
See also Connector::Role::LocalPath
Pattern for Template Toolkit to build the content. The data is passed "as is". If data is a scalar, it is wrapped into a hash using DATA as key.
append: opens the file for appending write.
fail: call die
die
silent: fail silently.
replace: replace the file with the new content.
Filesystem permissions to apply to the file when a file is written using the set method. Must be given in octal notation, e.g. 0644. Default is to not set the permissions and rely on the systems umask.
Name of a user / group that the file should belong to.
Write data to a file.
$conn->set('filename', { NAME => 'Oliver', 'ROLE' => 'Administrator' });
See the file parameter how to control the filename. By default, files are silently overwritten if they exist. See the ifexists parameter for an alternative behaviour.
Fetch data from a file. See the file parameter how to control the filename.
my $data = $conn->get('filename');
my $conn = Connector::Builtin::File::Path->new({ LOCATION: /var/data/ file: [% ARGS.0 %].txt content: Hello [% NAME %] }); $conn->set('test', { NAME => 'Oliver' });
Results in a file /var/data/test.txt with the content Hello Oliver.
To install Connector, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Connector
CPAN shell
perl -MCPAN -e shell install Connector
For more information on module installation, please visit the detailed CPAN module installation guide.