expatmark has asked for the wisdom of the Perl Monks concerning the following question:
The relevant code is as follows. (Everything before it is just input gathering)
Any print statement within the 'for $station ...' loop is withheld until the start of the 'for $found ...' sub loop. So the line print "\n $station"; right at the top does not print until the start of this last sub loop.for $station (@stations){ print "\n $station"; print OUTFILE "\n$station"; undef %found; splice @found; for $stage (@stages){ chdir "/opt/stc/db/$station/$stage/prod/doc"; @files = <MO*>; for $file (@files){ open HTMFILE, "< $file"; for $line (<HTMFILE>){ if ($line =~ /${monobj}/ && $line =~ /HREF/ && $line ! +~ /TOP/){ $found = $stage,$file"; $found{$found} = (split /-/, $line)[0]; } } close HTMFILE; } } @found = sort (keys %found); for $found (@found){ ($stage) = (split /,/, $found)[0]; print "\t- $stage - $found{$found}\n"; print OUTFILE ",$stage,$found{$found}\n"; } print "\n" if ($found[0] eq ""); print OUTFILE "\n" if ($found[0] eq ""); }
It's not a major issue. The printout looks exactly how I want it but it is bugging me. Since the @files can contain between 2000 and 3500 entries, it would be nice to have the value of $station printed out where I put it as this would give a better progress indication.
All suggestions gratefully received and tried.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Not printing when expected.
by no_slogan (Deacon) on May 26, 2014 at 13:45 UTC | |
|
Re: Not printing when expected.
by Laurent_R (Canon) on May 26, 2014 at 21:46 UTC |