OK, I've been beating my head against the wall for most of the morning on this... I have to ask for help.

use Config::Simple; $cfg = new Config::Simple(); $cfg->read('c:\work\ftp_config_file.txt'); for ($ct=0, $cfg->param("FTP".$ct.".targetIP")!= '', $ct++) { print " FTP$ct value: ".$cfg->param("FTP$ct.targetIP")."\n"; }

Is displaying the following output:


FTP1 value: 1.1.1.1
FTP1 value: 1.1.1.1
FTP1 value: 1.1.1.1

The c:\work\ftp_config_file.txt contains the following values:

[FTP1] targetIP=1.1.1.1 [FTP2] targetIP=10.10.10.10

For the life of me, I can't see what is causing this to loop three times without incrementing the counter..

I get the correct output when I run the script as such:

use Config::Simple; $cfg = new Config::Simple(); $cfg->read('c:\work\ftp_config_file.txt'); my $ct=1; print " FTP$ct value: ".$cfg->param("FTP$ct.targetIP")."\n"; $ct++; print " FTP$ct value: ".$cfg->param("FTP$ct.targetIP")."\n";

thanks in advance those monks who are most intelligent at deciphering a moron's code. :)


In reply to Need Debug Help by naveed010

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.