if (/$beg/ .. (/$end/ || eof )) { ... }
if (/$beg/ .. (/$end/ || eof(INFILE) )) { ... }
but the original will not:
if (/$beg/ .. (/$end/ || eof() )) { ... }
After figuring this out, I checked a few resources (the best explanation came from perlfunc eof):
An eof without an argument uses the last file read as argument. Using eof() with empty parentheses is very different. It indicates the pseudo file formed of the files listed on the command line, i.e., eof() is reasonable to use inside a while (<>) loop to detect the end of only the last file.
Obvously, I made some faulty assumptions as to how eof() works. Given how seldom I've actually used eof, I should've checked the docs when I first encountered the "freeze-up" problem.
--Jim | [reply] [d/l] [select] |
Thanks for replying merlyn. Actually, this is one of the variations I tried, but it goes into an infinite loop in the first file after hitting the range statement on the fourth iteration (I believe when the successful /$end/ match occurs).
--Jim | [reply] |