in reply to Inappropriate I/O control operation

Update: OIC, you are using $! in your print statement. I missed that. Why? What are you trying to print?

As explained below by dave_the_m, you use $! after an error when it might hold a message about the error (if whatever encountered the error is nice enough to tell you). That's why I used it to check the return value of your file open call, which is where I assumed the error was coming from: it will tell you if you've made a typo in the path and the file does not exist, for example. In your case it is printing something unuseful because you're not using it the right way. What did you want to print there?

Original reply:


Try adding error checking and debugging to your program:

open(my $in, '<', $fn) or die "Died opening file: $fn error: $!";
Also note the three argument form of open, which is safer.

Hope this helps!


The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re^2: Inappropriate I/O control operation
by cormanaz (Deacon) on Sep 26, 2017 at 17:02 UTC
    Thanks for the suggestion. I did print $! in the statement underneath the open in the original script. But I modified the open per your suggestion. It didn't die on any of the opens but still gave the error in $! in the following line. Then I tried reading and printing the first line of each file and it worked. Strange.
      $! is only meaningful after an error. Its value after a successful open is unspecified and could be anything.

      Dave.