Usually, it doesn't do anything. (...) In order for it to do anything at all, you have to be either A) using a perl <= 5.00404 or B) doing something more complex in your while loop than a simple assignment from a filehandle read and one of the following must be true: 1) you are reading fixed length records and retrieve a record containing all '0's, 2) you have set $/ to a string of one or more '0's, or 3) the last line of a file you are reading must contain a string of one or more '0's and not be terminated with $/.

So by routinely adding 9 characters that are easy to remember, I no longer have to remember these 6 permutations that I will probably forget again within the next hour.

Just like how by using strict, I don't have to remember that undeclared variables are implicitly global.

I do not mind typing a little more if that means that I can forget a lot and get away with it.

Especially since the extra code cannot introduce a bug, but only prevent obscure ones, please let me and the rest of the world type "defined". Perl thinks it is needed too: it adds the test in case you forget it. That's how important perl thinks it is, and I agree with perl. I agree strongly enough to explicitly use that "defined".

I wish everyone continues to use defined. I hope that tutorials and books will continue to preach it, even when it isn't necessary. This is just like "use strict;" in many ways: the extra keystrokes prevent bad things.

I sincerely hope that not too many beginners read your post, and that people who already know Perl well are sane enough to evaluate and then disregard it.

How do you feel about the "return" statement as the last statement in a sub? I like it and use it whenever I can (i.e. when the sub is not an lvalue-sub), even though Perl implicitly returns the last evaluated expression anyway.

Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }


In reply to Re: Re: Re: To Kill a Meme: while(defined($line = <>)) by Juerd
in thread To Kill a Meme: while(defined($line = <>)) by sauoq

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.