Here is a .pl file = IMSLOOK.pl, in this file i need to pull out some static variable value into a text file. so all the static var info will be retreive from the text file. To retreive the static info from the text file, there is another file loadconfig.pl which store the function to load the static info into the cgi file. emm sorry can one package call to another package?

here is the the part of the IMSLook.pl:

--------------------------------------- package IMSLook; use Socket; use CGI qw/:standard/; require "LDAPLook.pl"; require "LDAPAdd.pl"; require "LoadConfig.pl"; # ----------------------------------------------------------# global v +ariables # ----------------------------------------------------------my %server +con = &LoadConfig::LoadConfig("server.conf"); my $hostname = $servercon{'hostname'}; my $port = $servercon{'port'}; my $password = $servercon{'password'}; my $logdir = $servercon{'logdir'}; sub IMSConnect { my $response; my $iaddr = inet_aton($hostname) || die "no host: $server"; my $paddr = sockaddr_in($port, $iaddr); my $proto = getprotobyname('tcp'); # Open socket connection to the server socket($sock, PF_INET, SOCK_STREAM, $proto) || die "socket: $!"; connect($sock, $paddr) || die "unable to connect"; select($sock); $| = 1; select(STDOUT); &SOCKETread($sock); &SOCKETwrite($sock, "LOGIN $password WRITE\n"); $response = &SOCKETread($sock); if ($response =~ /.*OK.*/) { &TaskLog("IMSLook sub::IMSConnect: Successfully connected +to IMS\n"); return 0; } &TaskLog("IMSLook sub::IMSConnect: Access denied to IMS, possibly +invalid password\n"); return 1; } Here is the part for the LoadConfig.pl function : -------------------------------------------------- package LoadConfig; use IO::Handle; sub LoadConfig() { $config_file = $_[0]; #open a file handle open(MYHANDLE, "<$config_file") or die "could not open file"; while (<MYHANDLE>) { chomp; s/#.*//; # no newline s/^\s+//; s/\s+$//; next unless length; my ($var, $value) = split(/\s*=\s*/, $_, 2); $User_Preferences{$var} = $value; } return %User_Preferences; } # ~LoadConfig() 1; here is the the part of the text file name Server.conf: -------------------------------------------------------- hostname="sgsms.asia.com" port="4200" password="p" logdir="C:\\tempperl" host='sgsmld.d1asia.com:351' host392='sgsmld.asia.com:352'
the problem is when i run, the apache server error log giving me the error that say i dun supply the host name for them. It mean the $hostname in (sub IMSConnect) didn't get any value can anyone check it for me. Thank you

Petruchio - Wed Jul 11 02:24:01 EDT 2001 - Added code and p tags.


In reply to can anyone help to detect any error in this script by Anonymous Monk

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.