ratboy has asked for the wisdom of the Perl Monks concerning the following question:

When I run this code and it finds the last type of report, the program hangs until I hit enter for each report of this type. I would like for it NOT to do this. What sort of goofy logic error have I committed here?

foreach $xreport (@list) { # code to check to see which subroutine is needed if ($xreport =~ m/XSAColorQube/) { $count++; &Qube; } elsif ($xreport =~ m/XSAcolor/) { $count++; &Color; } elsif ($xreport =~ m/XSAreport/) { $count++; # some have fax, some do not, reports differ, checking open(XRPT,"<$xreport") or die "Cannot open $xreport: $ +!\n"; $line = readline(*STDIN); close(XRPT); if ($line =~ m/EFax/) { &Regular; } else { &NoFax; } } else { print "$xreport does not match expected naming scheme +and was not processed.\n"; } } print "-------------------------------------------\n"; print "Processed $count files.\n"; print "Output combined into report myxrxrpt.csv.\n"; close(OUT);

Replies are listed 'Best First'.
Re: Pausing on extra IF
by choroba (Cardinal) on Sep 30, 2011 at 15:50 UTC
    What do you think this line does?
    $line = readline(*STDIN);
    Update: You probably meant something like
    $line = <XRPT>;
      HA! That's funny. What a dopey thing to do! Just before i read this I ran a test on that and found it is not doing what I intended. "STDIN"?! That solves TWQ problems! :-) I knew if I embarrassed myself I'd get it resolved. Thanks