Skip Menu |

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

Report information
The Basics
Id: 14162
Status: resolved
Priority: 0/
Queue: Config-Std

People
Owner: Nobody in particular
Requestors: luke [...] daeron.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.0.2
Fixed in: 0.007



Subject: hashref version of write_config seems to be broken
When reading and writing a config, the hash form works, but not the hashref form. The first section below works, but not the second. Maybe something tricky about how you're using the hashref as a string directly to identify itself? Dunno: Show quoted text
> cat foo.t
use Config::Std; read_config "Std.cfg", my %config; $config{section2}{mutating}++; write_config %config; read_config "Std.cfg", my $config_ref; $config_ref->{section2}{mutating}++; write_config $config_ref; Show quoted text
> cat Std.cfg
[section2] mutating: 17 Show quoted text
> perl foo.t
Missing filename for call to write_config() at foo.t line 9 ---------------------- Installed from CPAN's Config-Std-0.0.2.tar.gz perl -V Summary of my perl5 (revision 5 version 8 subversion 6) configuration: Platform: osname=darwin, osvers=8.0, archname=darwin-thread-multi-2level uname='darwin b28.apple.com 8.0 darwin kernel version 7.5.0: thu mar 3 18:48:46 pst 2005; root:xnuxnu-517.99.13.obj~1release_ppc power macintosh powerpc ' config_args='-ds -e -Dprefix=/usr -Dccflags=-g -pipe -Dldflags=-Dman3ext=3pm -Duseithreads -Duseshrplib' hint=recommended, useposix=true, d_sigaction=define usethreads=define use5005threads=undef useithreads=define usemultiplicity=define useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-g -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -I/usr/local/include', optimize='-Os', cppflags='-no-cpp-precomp -g -pipe -fno-common -DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -I/usr/local/include' ccversion='', gccversion='3.3 20030304 (Apple Computer, Inc. build 1809)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags ='-L/usr/local/lib' libpth=/usr/local/lib /usr/lib libs=-ldbm -ldl -lm -lc perllibs=-ldl -lm -lc libc=/usr/lib/libc.dylib, so=dylib, useshrplib=true, libperl=libperl.dylib gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-bundle -undefined dynamic_lookup -L/usr/local/lib' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES PERL_IMPLICIT_CONTEXT Locally applied patches: 23953 - fix for File::Path::rmtree CAN-2004-0452 security issue 33990 - fix for setuid perl security issues Built under darwin Compiled at Mar 20 2005 16:34:19 @INC: /System/Library/Perl/5.8.6/darwin-thread-multi-2level /System/Library/Perl/5.8.6 /Library/Perl/5.8.6/darwin-thread-multi-2level /Library/Perl/5.8.6 /Library/Perl /Network/Library/Perl/5.8.6/darwin-thread-multi-2level /Network/Library/Perl/5.8.6 /Network/Library/Perl /System/Library/Perl/Extras/5.8.6/darwin-thread-multi-2level /System/Library/Perl/Extras/5.8.6 /Library/Perl/5.8.1 .
From: luke [...] daeron.com
Actually, I see the problem. The hash_ref below is a scalar ref when used that way: sub write_config (\[%$];$) { my ($hash_ref, $filename) = @_; $filename = $filename_for{$hash_ref} if @_<2; croak "Missing filename for call to write_config()" unless $filename; Just need to add: $hash_ref = $$hash_ref if ref($hash_ref) eq 'SCALAR';
Date: Thu, 18 Aug 2005 09:35:49 -0700
From: Damian Conway <damian [...] conway.org>
To: bug-Config-Std [...] rt.cpan.org
Subject: Re: [cpan #14162] hashref version of write_config seems to be broken
RT-Send-Cc:
Show quoted text
> Actually, I see the problem. The hash_ref below is a scalar ref when > used that way: > > sub write_config (\[%$];$) { > my ($hash_ref, $filename) = @_; > > $filename = $filename_for{$hash_ref} if @_<2; > > croak "Missing filename for call to write_config()" > unless $filename; > > > Just need to add: > > $hash_ref = $$hash_ref if ref($hash_ref) eq 'SCALAR';
Patched. Many thanks for the report. And even more thanks for finding the fix! ;-) Damian
late close - fixed by prior maintainer as per comments but not closed.