Scott T. Hardin

Name

Connector::Builtin::File::Path

Description

Highly configurable file writter/reader.

Parameters

LOCATION

The base directory where the files are located. This parameter is mandatory.

file

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.

content

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.

ifexists
  • append: opens the file for appending write.

  • fail: call die

  • silent: fail silently.

  • replace: replace the file with the new content.

Supported Methods

set

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.

get

Fetch data from a file. See the file parameter how to control the filename.

    my $data = $conn->set('filename');

Example

    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.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 217:

You forgot a '=back' before '=head1'




Hosting generously
sponsored by Bytemark