[Chicago-talk] How would I do this

JT Smith jt at plainblack.com
Sat Mar 25 13:25:22 PST 2006


I don't know, but I'd say it's expecting a reference from the FileHandle object.

my $fh = FileHandle->new;
$fh->open("< $file");

my %config = ParseConfig(-ConfigFile=>\$file);

You may also be able to do it like this using a traditional file handle:

my %config = ParseConfig(-ConfigFile=>\*FILE);




On Sat, 25 Mar 2006 15:06:51 -0600
  Jay Strauss <me at heyjay.com> wrote:
> I'm trying to get Config::General to read my __DATA__ section.  But I don't 
> know how to make it read it.  The docs say it can read a filehandle, but I 
> don't know how to turn <DATA> into $filehandle.  I've been trying all 
> different combinations like:
> 
> my %config = ParseConfig(-ConfigFile => \DATA);
> my %config = ParseConfig(-ConfigFile => \<DATA>);
> my %config = ParseConfig(-ConfigFile => DATA);
> 
> But don't know how to do it.
> 
> An example of how to do it would be tremendous
> Thanks
> Jay
> 
> In:
> #!/usr/bin/perl
> 
> use Config::General;
> 
> my %config = ParseConfig(-ConfigFile => \DATA);
> 
> use Data::Dumper;
> print Dumper(%config);
> 
> __DATA__
> 
> somekey somevalue
> 
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk


JT ~ Plain Black
ph: 703-286-2525 ext. 810
fax: 312-264-5382
http://www.plainblack.com

I reject your reality, and substitute my own. ~ Adam Savage


More information about the Chicago-talk mailing list