Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: More heredoc fun w/ Config::IniHash

by Belgarion (Chaplain)
on Dec 03, 2005 at 02:36 UTC ( #513766=note: print w/replies, xml ) Need Help??


in reply to More heredoc fun w/ Config::IniHash

I haven't used Config::IniHash, but looking at the documentation it looks like you want something like:

use Config::IniHash; my $config = ReadINI("/ini/file/to/read.ini", heredoc => 1)

That should set the heredoc style on when reading the ini file. Untested of course, but the module seems pretty standard.

Replies are listed 'Best First'.
Re^2: More heredoc fun w/ Config::IniHash
by hesco (Deacon) on Dec 03, 2005 at 11:41 UTC
    Thank you Belgarion:

    I too read that documentation. Below are the salient portions of my test script. As you can see, I am using his suggested syntax. My test page at http://new.greenpartyblackcaucus.net/cgi-bin/test.pl seems to be pulling the non-heredoc variables from the .db.ini and the .conf.ini files. But my attempts to harvest the .copy.ini file using the heredoc feature yeilds a blank field, where I expected to see a paragraph of text.

    I'm hoping to hear from someone who has made this feature work.

    #!/usr/bin/perl use strict; # use supporters_conf qw(%config); use Config::IniHash; # $hashreference = ReadINI ($filename, %options); use CGI; use CGI::Pretty qw(:all *table param); my $url = url(); # my $table1 = fqtn(@config{qw(db prefix)},"basetablename"); my $conf = parse_config_directory($url); my $path = $0; my $script = $0; $script =~ s/^(.*)\///; # $conf =~ s/$script//; # $path =~ s/$script/conf.d\/$conf\/supporters.conf/; my $config_conf = ReadINI ($conf); my $copy = $conf; $copy =~ s/\.conf/.copy/; my %options; $options{'heredoc'} = 1; # my $config_copy = ReadINI ($copy,%options); my $config_copy = ReadINI ($copy, heredoc => 1 ); my $db = $conf; $db =~ s/\.conf/.db/; my $config_db = ReadINI ($db); print header("Testing parser for configuration files"), start_html("Testing parser for configuration files"), p("And the question of the hour is: Will the config module export t +he form copy. This experiment shall tell us."), p("Script path and name is: ".$0), p("Script name is: ".$script), # p("Scriptpath: ".$sp), # p("Scriptname: ".$sn), p("Path to configuration files at: <b>".$conf."</b>"), p("Script accessible at: ".$url), # p("Fully Qualified Table Name looks like: ".$table1), p("Config::IniHash says \$config = ".$config_conf."."), p("And the mail-abuse address is: ".$config_conf->{'mail-server'}->{ +'mail_abuse'}."."), p("The database name is: ".$config_db->{'db'}->{'db_name'}."."), p("The donor form disclaimer reads: <br>".$config_copy->{'copy'}->{' +donor_form_disclaimer_copy'}."."), p(),p(), $supporters_conf::config{'donor_thanks'}, end_html();
    I cut the subroutines which support this.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://513766]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2023-03-21 09:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which type of climate do you prefer to live in?






    Results (59 votes). Check out past polls.

    Notices?