Hello fellow monks, I am still learning this interesting language we call Perl and am looking for some assistance (again). I want to get some information out of a file on the server that I can then check input from a HTML form against. For example if UserX enters "Star" into text field 'INPUT1' and then "Wars" into 'INPUT2', I would then like to check that these inputs match two fields in a Config file. I have made some dummy code below, the problem I am getting is when I call the PARSEINFO package, and specifically when I use Config::IniFiles. I have commented out everything except for the below code in the PARSEINGO package:
#!c:\Perl\bin\perl use warnings; use strict; package PARSEINFO;
and have had no problems. Also in the actual code it all compiles fine. The problem I get is that I receive a Internal Server Error as soon as I uncomment "use Config::IniFiles;". My test code is:
#!c:\Perl\bin\perl use warnings; use strict; use PARSEINFO; use GUI; use CGI qw(:standard); use constant PASS => 1; my $i_input1 = param('INPUT1'); my $i_input2 = param('INPIT2'); my %data; &PARSEINFO::ParseConfigFileToHash( 'c:\inifile.ini', \%data ); if( ($i_input1 eq $data{input1}) && ($i_input2 eq $data{input2}) ) { if( ($i_input2) || ($i_input1) ) { my @args = ("../bin/Script.exe", $i_input1, $i_input2); system(@args); my $result = $? >>8; if ( $result == PASS) { &GUI::HtmlDoc1(); } else { &GUI::HtmlDoc2(); } } else { &GUI::HtmlDoc3(); } } else { &GUI::HtmlDoc2(); } exit (0);
and my PARSEINFO package (PARSEINFO.pm) code is:
#!c:\Perl\bin\perl use warnings; use strict; use Config::IniFiles; package PARSEINFO; sub ParseConfigFileToHash { my $ini_file = shift; my $cfg = Config::IniFiles->new( -file => $ini_file ); my $hashref = shift; $hashref->{input1} = $cfg->val( 'SETTINGS', 'INPUT1'); $hashref->{input2} = $cfg->val( 'SETTINGS', 'INPUT2'); } sub OutputConfigFile{ my $ini_file = shift; my $newConfigFile = Config::IniFiles->new( ); $newConfigFile->SetFileName( $ini_file ); my $hashref = shift; my $sectionName = 'SETTINGS'; $newConfigFile->newval( $sectionName, 'INPUT1', $hashref->{ +input1} ); $newConfigFile->newval( $sectionName, 'INPUT2', $hashref->{ +input2} ); $newConfigFile->RewriteConfig(); $newConfigFile->WriteConfig( $ini_file ); } 1;
I know that the GUI Package works fine and the HTMLDOC1, 2 and 3 all have no problems. Thank you in adavnce for any assistance you can offer.

In reply to Using Config::IniFiles in CGI by KyussRyn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.