j0e has asked for the wisdom of the Perl Monks concerning the following question:

I'm probably missing something simple, but right now I'm stumped. The program I'm writing gets some of its variables from a configuration file, via the following code:
open(CONFIG, "$cfgfile") or die "Can't open configuration file: $!"; while (<CONFIG>) { if (/^#/ or /^\n$/) { next; } else { chomp; s/\s//g; (my $n, my $v) = split(/=/); $CFG{$n} = $v; } } close(CONFIG);
Everything seems to work fine there. However, one of the variables is the hostname of a pop3 server ($CFG{pop3_host}). If I call  Net::POP3->new($CFG{pop3_host}) the connection to the pop3 server times out. However, this does not happen if I simply define the pop3_host variable statically (i.e.  $CFG{pop3_host} = "hostname"). Egad, what the heck is going on?

Replies are listed 'Best First'.
Re: Weird Net::POP3 problem
by dws (Chancellor) on Apr 13, 2001 at 05:50 UTC
    Debugging with print can often be quite revealing. What does   print 'pop3_host="', $CFG{'pop3_host'}, '"', "\n"; show?

      I get the following output:
      pop3_host="ryoko"
      That seems to be correct; ryoko is the hostname of the pop3 server, and I get the same output if I define the variable statically. Very weird.
        If both "versions" of "ryoko" consistently yield different results, despite appearing identically, your assumption that they are the same value is invalid. The likely possibility is that there are unprintable characters in the string. If the file was generated under MS-DOS, for instance, you might be seeing a trailing ^Z or something. Newline conventions might also be screwing you up, but if you saw a quotation mark followed by ryoko followed by another quotation mark, that's probably not it.

        I would try splitting the string up and examining each byte, printing its value. That way you can be sure the strings are truly identical. (That, or use 'eq' I guess.)

        And does one of the two ryoko's yield a hang?

Re: Weird Net::POP3 problem
by j0e (Acolyte) on Apr 13, 2001 at 08:25 UTC
    Uh, like, never mind. I frogot that I had taint-checking enabled. That seemed to be screwing it up.
      Screwed it up how?

      Enquiring minds want to know.

      Your message indicated that your problem was that the connection was hanging. It made no mention of any tainting-related error messages. What happened?
        I simply turned off Taint-Checking and it worked like a charm. I didn't receieve any taint checking error messages when I had it enabled. Now that I think about it, its pretty wierd that taint checking would cause my problem...