Skip Menu |

This queue is for tickets about the Config-IniFiles CPAN distribution.

Report information
The Basics
Id: 57536
Status: resolved
Priority: 0/
Queue: Config-IniFiles

People
Owner: Nobody in particular
Requestors: tom [...] audioboundary.com
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in: 2.57
Fixed in: (no value)



Subject: Minor documentation style updates
Hi rindolf, Minor patch to the documentation to convert some indirect notation into Config::IniFiles->new format: --- orig.pm 2010-05-16 21:18:20.000000000 +0100 +++ lib/Config/IniFiles.pm 2010-05-16 21:24:30.000000000 +0100 @@ -20,7 +20,7 @@ =head1 SYNOPSIS use Config::IniFiles; - my $cfg = new Config::IniFiles( -file => "/path/configfile.ini" ); + my $cfg = Config::IniFiles->new( -file => "/path/configfile.ini" ); print "The value is " . $cfg->val( 'Section', 'Parameter' ) . "." if $cfg->val( 'Section', 'Parameter' ); @@ -86,7 +86,7 @@ Get a new Config::IniFiles object with the I<new> method: $cfg = Config::IniFiles->new( -file => "/path/config_file.ini" ); - $cfg = new Config::IniFiles -file => "/path/config_file.ini"; + $cfg = new Config::IniFiles:: -file => "/path/config_file.ini"; Optional named parameters may be specified after the configuration file name. See the I<new> in the B<METHODS> section, below. @@ -119,26 +119,31 @@ 1) the pathname of a file - $cfg = new Config::IniFiles -file => "/path/to/config_file.ini"; + $cfg = Config::IniFiles->new( -file => "/path/to/config_file.ini" ); 2) a simple filehandle - $cfg = new Config::IniFiles -file => STDIN; + $cfg = Config::IniFiles->new( -file => STDIN ); 3) a filehandle glob open( CONFIG, "/path/to/config_file.ini" ); - $cfg = new Config::IniFiles -file => *CONFIG; + $cfg = Config::IniFiles->new( -file => *CONFIG ); 4) a reference to a glob open( CONFIG, "/path/to/config_file.ini" ); - $cfg = new Config::IniFiles -file => \*CONFIG; + $cfg = Config::IniFiles->new( -file => \*CONFIG ); 5) an IO::File object - $io = new IO::File( "/path/to/config_file.ini" ); - $cfg = new Config::IniFiles -file => $io; + $io = IO::File->new( "/path/to/config_file.ini" ); + $cfg = Config::IniFiles->new( -file => $io ); + + or + + open my $fh, '<', "/path/to/config_file.ini" or die $!; + $cfg = Config::IniFiles->new( -file => $fh ); 6) A reference to a scalar (requires newer versions of IO::Scalar) @@ -148,7 +153,7 @@ Setting=Another value EOT - $cfg = new Config::IniFiles -file => $ini_file_contents; + $cfg = Config::IniFiles->new( -file => $ini_file_contents ); If this option is not specified, (i.e. you are creating a config file from scratch) @@ -173,7 +178,7 @@ If you create your Config::IniFiles object with a default section of "all" like this: - $cfg = new Config::IniFiles -file => "file.ini", -default => "all"; + $cfg = Config::IniFiles->new( -file => "file.ini", -default => "all" ); Then requsting a value for a "permissions" in the [joe] section will check for a value from [all] before returning undef. @@ -2066,7 +2071,7 @@ if (ref($thing) eq "SCALAR") { if (eval { require IO::Scalar; $IO::Scalar::VERSION >= 2.109; }) { - return new IO::Scalar($thing); + return IO::Scalar->new($thing); } else { warn "SCALAR reference as file descriptor requires IO::stringy ". "v2.109 or later" if ($^W); @@ -2303,8 +2308,8 @@ file, the latter taking precedence. For example, let's say that C<$master> and C<overlay> were created like this: - my $master = new Config::IniFiles(-file => "master.ini"); - my $overlay = new Config::IniFiles(-file => "overlay.ini", + my $master = Config::IniFiles->new(-file => "master.ini"); + my $overlay = Config::IniFiles->new(-file => "overlay.ini", -import => $master); If the contents of C<master.ini> and C<overlay.ini> are respectively @@ -2332,9 +2337,9 @@ much shorter, per-site configuration file. Assuming UNIX-style path names, this would be done like this: - my $defaultconfig=new Config::IniFiles + my $defaultconfig = Config::IniFiles->new (-file => "/usr/share/myapp/myapp.ini.default"); - my $config=new Config::IniFiles + my $config = Config::IniFiles->new (-file => "/etc/myapp.ini", -import => $defaultconfig); # Now use $config and forget about $defaultconfig in the rest of # the program Tom
Hi Tom, Thanks for the patch. On Sun May 16 15:27:27 2010, TomM wrote: Show quoted text
> Hi rindolf, >
Please call me "Shlomi" off IRC, Show quoted text
> Minor patch to the documentation to convert some indirect notation into > Config::IniFiles->new format: > > --- orig.pm 2010-05-16 21:18:20.000000000 +0100 > +++ lib/Config/IniFiles.pm 2010-05-16 21:24:30.000000000 +0100 > @@ -20,7 +20,7 @@ > =head1 SYNOPSIS >
Well, I cannot patch this file directly to the svn trunk: http://config-inifiles.svn.sourceforge.net/svnroot/config-inifiles/trunk/config-inifiles As a result, I'm bouncing it, and request that you: 1. Make sure it applies cleanly against the svn trunk. Preferably use the "svn diff" command to generate it. 2. Attach it as a separate file (not inline in your comment). 3. Get rid of the "new Config::IniFiles::" line. Beginners may find it confusing and it is still a bad practice that we'd like not to encourage. ------------ Thanks, though, but please deal with the problems I've mentioned. Regards, -- Shlomi Fish
From: tom [...] audioboundary.com
Updated to remove "new Config::IniFiles::" notation and applied against svn trunk as requested. Note that there's also one non-documentation change (indirect notation again), I can separate this out if preferred. cheers, Tom
Subject: 2010-05-16-indirect-object-notation.patch
Index: lib/Config/IniFiles.pm =================================================================== --- lib/Config/IniFiles.pm (revision 177) +++ lib/Config/IniFiles.pm (working copy) @@ -20,7 +20,7 @@ =head1 SYNOPSIS use Config::IniFiles; - my $cfg = new Config::IniFiles( -file => "/path/configfile.ini" ); + my $cfg = Config::IniFiles->new( -file => "/path/configfile.ini" ); print "The value is " . $cfg->val( 'Section', 'Parameter' ) . "." if $cfg->val( 'Section', 'Parameter' ); @@ -119,27 +119,32 @@ 1) the pathname of a file - $cfg = new Config::IniFiles -file => "/path/to/config_file.ini"; + $cfg = Config::IniFiles->new( -file => "/path/to/config_file.ini" ); 2) a simple filehandle - $cfg = new Config::IniFiles -file => STDIN; + $cfg = Config::IniFiles->new( -file => STDIN ); 3) a filehandle glob open( CONFIG, "/path/to/config_file.ini" ); - $cfg = new Config::IniFiles -file => *CONFIG; + $cfg = Config::IniFiles->new( -file => *CONFIG ); 4) a reference to a glob open( CONFIG, "/path/to/config_file.ini" ); - $cfg = new Config::IniFiles -file => \*CONFIG; + $cfg = Config::IniFiles->new( -file => \*CONFIG ); 5) an IO::File object - $io = new IO::File( "/path/to/config_file.ini" ); - $cfg = new Config::IniFiles -file => $io; + $io = IO::File->new( "/path/to/config_file.ini" ); + $cfg = Config::IniFiles->new( -file => $io ); + or + + open my $fh, '<', "/path/to/config_file.ini" or die $!; + $cfg = Config::IniFiles->new( -file => $fh ); + 6) A reference to a scalar (requires newer versions of IO::Scalar) $ini_file_contents = <<EOT @@ -148,7 +153,7 @@ Setting=Another value EOT - $cfg = new Config::IniFiles -file => $ini_file_contents; + $cfg = Config::IniFiles->new( -file => $ini_file_contents ); If this option is not specified, (i.e. you are creating a config file from scratch) @@ -173,7 +178,7 @@ If you create your Config::IniFiles object with a default section of "all" like this: - $cfg = new Config::IniFiles -file => "file.ini", -default => "all"; + $cfg = Config::IniFiles->new( -file => "file.ini", -default => "all" ); Then requsting a value for a "permissions" in the [joe] section will check for a value from [all] before returning undef. @@ -2066,7 +2071,7 @@ if (ref($thing) eq "SCALAR") { if (eval { require IO::Scalar; $IO::Scalar::VERSION >= 2.109; }) { - return new IO::Scalar($thing); + return IO::Scalar->new($thing); } else { warn "SCALAR reference as file descriptor requires IO::stringy ". "v2.109 or later" if ($^W); @@ -2303,8 +2308,8 @@ file, the latter taking precedence. For example, let's say that C<$master> and C<overlay> were created like this: - my $master = new Config::IniFiles(-file => "master.ini"); - my $overlay = new Config::IniFiles(-file => "overlay.ini", + my $master = Config::IniFiles->new(-file => "master.ini"); + my $overlay = Config::IniFiles->new(-file => "overlay.ini", -import => $master); If the contents of C<master.ini> and C<overlay.ini> are respectively @@ -2332,9 +2337,9 @@ much shorter, per-site configuration file. Assuming UNIX-style path names, this would be done like this: - my $defaultconfig=new Config::IniFiles + my $defaultconfig = Config::IniFiles->new (-file => "/usr/share/myapp/myapp.ini.default"); - my $config=new Config::IniFiles + my $config = Config::IniFiles->new (-file => "/etc/myapp.ini", -import => $defaultconfig); # Now use $config and forget about $defaultconfig in the rest of # the program
On Sun May 16 16:04:37 2010, TomM wrote: Show quoted text
> > Updated to remove "new Config::IniFiles::" notation and applied against > svn trunk as requested. Note that there's also one non-documentation > change (indirect notation again), I can separate this out if preferred. >
Thanks! Applied and uploaded to CPAN. The problem was that there was a CR-LF/LF mismatch, but I fixed it. Closing the bug as resolved. Regards, -- Shlomi Fish Show quoted text
> cheers, > > Tom