in reply to Why my perl script skip my some of the executed lines even without using conditions??

I assume you are not posting all the code (maybe this is a good thing), but one important thing that is missing here is "use strict" -- you do have a lot of "my" declarations, so if you aren't using stricture, it shouldn't be hard to add.

Anyway, given what you have posted, I would be surprised if the execution went beyond this block:

if ($totalFound eq scalar(@userArray)) { exit (0); }
Near as I can tell, you don't have any code that adds an element to @userArray -- so scalar() on that would always be zero. Then, the part that increments $totalFound is inside a loop over the elements of @userArray -- and since that is always zero, $totalFound never gets incremented, so when the above if statement is ever reached, that is where the script will exit, every time.

As for how to track what's going on, the perl debugger is pretty easy to learn; read the perldebug man page, and run the script with "perl -d". But before you do that, make sure you have "use strict;", and try "-w" (or "use warnings;") as well. Maybe try a little refactoring while you're at it...

  • Comment on Re: Why my perl script skip my some of the executed lines even without using conditions??
  • Download Code

Replies are listed 'Best First'.
Re^2: Why my perl script skip my some of the executed lines even without using conditions??
by fabster01 (Initiate) on Apr 12, 2006 at 09:22 UTC
    I have not tried using "use strict" but the strangest thing is IF i run a "perl -d" over my script I am actually able to run the codes line by line and it completes successfully but when I were to run it using "perl -w" or "perl" it will stop pass the line 333
    : : Line 331: close(FILE) or die "can't close $backupP +athDir: $!"; Line 332: close(NEW) or die "can't close $ldap_mov +e_file: $!"; Line 333: Line 334: my $test = `rm $backupPathDir`; Line 335: my $logfile = $step1_logfile . `date '+%m%d%Y'`; : :
    Sigh! Very very strange.... help!
Re^2: Why my perl script skip my some of the executed lines even without using conditions??
by fabster01 (Initiate) on Apr 12, 2006 at 10:02 UTC
    Hi Graff,

    You are correct! That was the problem.... as I was ripping my code all over again.... I then realized... thanks a lot.

    It is working again.... Thanks!