Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Very nice explanation. Perhaps I should fill in the details leading up to my original post:

While rereading Effective Perl Programming I noticed that it warned against constructs such as: while($line = <FILE>) and recommended using while(defined($line = <FILE>)) instead. The book is several years old ('97 I think??) and I knew that this particular issue had been dealt with in later versions of perl. I had also noticed a "real" erratum in the book and decided to track down the books errata page so I could keep track of such things as I read the book.

Well, it turns out that I couldn't find a list of errata... The best I could come up with was this empty page which looks lilke it should contain a list of errata but it doesnt. A one line '* this issue has been fixed in later versions' would have ended the story right there.

I then went looking for the documentation covering this automatic definedness feature. The trivial 'perldoc -f while' doesn't work, because while isn't a function. 'perldoc -q while | grep defined' didn't turn up anything, and searching for 'while and defined' over at perldoc.com or Super Search turned up way too much. I checked a few online docs around here, including perlop to no avail. It turns out that perlop is so long, the Monastery's copy is split in two... the info I was looking for was on the second page of perlop which would have ended my search had I found it.

Fine, the docs had failed me... I'd just have to figure it out on my own. B::Deparse to the rescue! After deparsing a dozen constructs, I was more confused than ever... <FILEHANDLE> seemed well behaved, I could make a few conclusions about how it would play with definedness and while. However, globbing didn't seem to play by the same rules. Sometimes it added the defined() sometimes it didn't. Hindsight shows that there was really only one case that didn't play nicely, but at the time it confused the hell out of me.

Frustrated, I posted to perlmonks, and the rest is covered quite nicely above.

So, this bug would have gone unnoticed had we not a missing errata page, a split man page and an intrepid new monk (i.e. robin) who happens to be a "sometime perl5-porter."

P.S. Thanks robin, you made my day.

-Blake


In reply to Re: A most obscure bug by blakem
in thread A most obscure bug by robin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (6)
As of 2024-04-24 08:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found