naveed010 has asked for the wisdom of the Perl Monks concerning the following question:
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. :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need Debug Help
by kyle (Abbot) on Jan 18, 2008 at 18:01 UTC | |
by naveed010 (Acolyte) on Jan 18, 2008 at 18:11 UTC | |
by olus (Curate) on Jan 18, 2008 at 18:34 UTC | |
|
Re: Need Debug Help
by apl (Monsignor) on Jan 18, 2008 at 18:02 UTC | |
|
Re: Need Debug Help
by toolic (Bishop) on Jan 18, 2008 at 18:01 UTC |