Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: •Re: Between-text range operator problem--eof() HELL

by jlongino (Parson)
on May 18, 2002 at 00:55 UTC ( [id://167451]=note: print w/replies, xml ) Need Help??


in reply to •Re: Between-text range operator problem
in thread Between-text range operator problem

Well, chalk one up for shaving serendipities. This morning while I was shaving, I had a flash--maybe I should've explicitly used eof(INFILE) instead of eof(). Unfortunately, I didn't have time to test it until I got home from work this evening.

Both of the following will work:

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://167451]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-20 01:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found