in reply to Re: Perl not able to read file
in thread Perl not able to read file
You don't have to close FILEHANDLE if you are immediately going to do another open on it, because open closes it for you. (See open.)Having said that, I would still explicitly close the file handle before reopening it. This looks cleaner and more understandable.
But the important point is that reopening the file for reading needs to be done after all required data has been printed to it.
An additional comment on the OP code is that there is no need to chomp the input line if the next statement adds a \n to it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Perl not able to read file
by choroba (Cardinal) on Sep 22, 2017 at 09:55 UTC | |
by Laurent_R (Canon) on Sep 22, 2017 at 10:04 UTC |