Hi I am a newbie. I have a very long code which I know can be simplified but that is my not question but my question is why when running the perl program, it skips some of the codes (stated below) and subs being called (in the example below it skipps sub printSummary). Is there a problem here? I am running it in a Solaris 10 environment.
------------------------------------ This is perl, v5.8.4 built for sun4-solaris-64int (with 27 registered patches, see perl -V for more detail) Copyright 1987-2004, Larry Wall ------------------------------------
My sub info is as below:
#-----Extract Moved Users-----# sub ExtractUsers { my $foundUser = "n"; my $foundDN = "n"; my $matchUser = -1; my $foundOrg = -1; my $lenLine = 0; my $readLine = 0; my $foundFirst = "n"; my $totalFound = 0; my $statusLine = 0; my $myArray = 0; print "ExtractUsers\n"; open(FILE, "< $backupPathDir") or die "Can't Find or Open +$backupPathDir: $!"; # File output - writing to print "backupPathDir: $backupPathDir\n";; open(NEW, "> $ldap_move_file") or die "can't open $ldap_mo +ve_file: $!"; print "ldap_move_file: $ldap_move_file\n"; while (<FILE>) { # Good practice to store $_ value because # subsequent operations may change it. my($line) = $_; # Good practice to always strip the trailing # newline from the line. chomp($line); #print "line = $line\n"; ++$readLine; ++$statusLine; if ($statusLine eq 20000) { print "Processing Lines: $readLine\n"; $statusLine = 0; } $lenLine = length($line); #print "lenline = $lenLine\n"; # Skip if found blank line and also statement with line id "en +try-id" if (($lenLine > 1) && (index($line,'entry-id') eq -1)){ # checking whether the line contains o=mail,dc=company,dc= +com $foundOrg = index($line, $org_suffix); if ($foundOrg > 0) { $foundUser = "n"; $foundDN = "y"; if ($totalFound eq scalar(@userArray)) { exit (0); } } #print "FoundOrg = $foundOrg\n"; #print "foundDN = $foundDN\n"; if ($foundDN eq "y") { $line =~ s/People/$move_suffix/g; #print "***Line = $line\n"; #$userArray = @userArray; foreach $myArray (@userArray) { #$userArray =$_; #print "userArray = $userArray\n"; $matchUser = index($line, $myArray); #print "matchuser = $matchUser\n"; if ($matchUser > 0) { if ($foundFirst eq "y") { # Insert a blank line after each users but + not for first found user (print NEW "\n") or die "can't write to + $ldap_move_file: $!"; } (print NEW $line . "\n") or die "can't writ +e to $ldap_move_file: $!"; $foundFirst = "y"; $foundUser = "y"; ++$totalFound; } else { $foundDN = "n"; } } } else { if ($foundUser eq "y") { if (index($line, "nsUniqueId") eq -1) { (print NEW $line . "\n") or die "can't writ +e to $ldap_move_file: $!"; } } } } } close(FILE) or die "can't close $backupPathDir: $ +!"; close(NEW) or die "can't close $ldap_move_file: $ +!"; my $test = `rm $backupPathDir`; my $logfile = $step1_logfile . `date '+%m%d%Y'`; chomp ($logfile); $logfile = "$logfile" . "." . $step1_log_ext; print "OutputLog: $logfile\n"; open(READ, "< $ldap_move_file") or die "Can't Find or Open + $ldap_move_file: $!"; # Appending TO the Log files open(WRITE, ">> $logfile") or die "Can't Find or Open $log +file: $!"; print WRITE "**Step #5 Creating a Move User LDIF File\n"; print WRITE "========================================\n"; while (<READ>) { # Good practice to store $_ value because # subsequent operations may change it. my($line) = $_; # Good practice to always strip the trailing # newline from the line. chomp($line); print WRITE "$line\n"; } print WRITE "\n"; close(READ) or die "can't close $ldap_move_file: +$!"; close(WRITE) or die "can't close $logfile: $!"; }
My main calling code of execution is below
#--Loading of parameters from deprovision.cfg--# LoadConfigParam; ExtractParameterStep1; PrintBanner; # Reading input file - reading from if (-e $verified_working_file) { ContinueYesNo; if ($answer eq "y") { #--Run DB2LDIF Before Changes--# $b4_after_status = $db2ldif_after_ext; Db2Ldif; ValidUserArray; ExtractUsers; PrintSummary; } }
Please note that from the line beginning with the command below onwards the lines have been skipped. I am still very confused why this is happening? How do I track it?
my $test = `rm $backupPathDir`;

Edit: g0n - readmore tags


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

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.