Config::Pg::ServiceFile - PostgreSQL connection service file parser
# ~/.pg_service.conf [foo] host=localhost port=5432 user=foo dbname=db_foo password=password # your_program.pl use Config::Pg::ServiceFile; # { # foo => { # host => 'localhost', # post => '5432', # user => 'foo', # dbname => 'db_foo', # password => 'passwird', # } # } my $hash_ref = Config::Pg::ServiceFile->read_file('~/.pg_service.conf');
Config::Pg::ServiceFile is a parser for the PostgreSQL connection service file. The connection service file is based on the INI format, but uses a # as the comment character. As such, this is a simple module that subclasses Config::INI::Reader, and replaces the comment character accordingly.
INI
#
The accompanying module Pg::ServiceFile provides a better interface to the data stored in a PostgreSQL connection file. See Pg::ServiceFile for more information.
Config::Pg::ServiceFile inherits all methods from Config::INI::Reader.
my $hash_ref = Config::Pg::ServiceFile->read_file($filename);
Given a filename, this method returns a hashref of the contents of that file.
my $hash_ref = Config::Pg::ServiceFile->read_handle($io_handle);
Given an IO::Handle, this method returns a hashref of the contents of that handle.
my $hash_ref = Config::INI::Reader->read_string($string);
Given a string, this method returns a hashref of the contents of that string.
Paul Williams <kwakwa@cpan.org>
Copyright 2018- Paul Williams
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Config::INI::Reader, Pg::ServiceFile, https://www.postgresql.org/docs/current/static/libpq-pgservice.html, https://github.com/postgres/postgres/blob/master/src/interfaces/libpq/fe-connect.c.
To install Config::Pg::ServiceFile, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Config::Pg::ServiceFile
CPAN shell
perl -MCPAN -e shell install Config::Pg::ServiceFile
For more information on module installation, please visit the detailed CPAN module installation guide.