Net::Server::Framework::Config - this lib is deprecated and only here


Net-Server-Framework documentation Contained in the Net-Server-Framework distribution.

Index


Code Index:

NAME

Top

Net::Server::Framework::Config - this lib is deprecated and only here for compatibility

VERSION

Top

This documentation refers to Net::Server::Framework::Config version 1.3.

DESCRIPTION

Top

This library is only listed for compatibility and needs to be replaced by one of the established configuration parser.

BASIC METHODS

Top

file2hash

This converts a INI style file into a hash

BUGS AND LIMITATIONS

Top

There are no known bugs in this module. Please report problems to Lenz Gschwendtner ( <lenz@springtimesoft.com> ) Patches are welcome.

AUTHOR

Top

Lenz Gschwendtner ( <lenz@springtimesoft.com> )

LICENCE AND COPYRIGHT

Top


Net-Server-Framework documentation Contained in the Net-Server-Framework distribution.

#!/usr/bin/perl

package Net::Server::Framework::Config;

use strict;
use warnings;
use Carp;

our ($VERSION) = '1.3';

sub file2hash {
    my $file = shift;

    open( my $FILE, q{<}, $file ) or croak "Could not open $file: $!";
    my $hash;
    while (<$FILE>) {
        if (
            my ( $key, $value ) =
            $_ =~ m{\A                  # beginning of string
                                              ^\s*             # trailing spaces are ignored
                                              ([^#/]           # match any string
                                              \S+)             # not starting with # or /
                                                                                # and not beeing a space
                                            \s+               # any number of spaces
                                            (.*)              # any character
                                            \n                # newlines at end of line 
                                            \z                # end of string
                                        }sxm
          )
        {
            $hash->{$key} = $value;
        }
    }
    return $hash;
}

1;