Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
while (<FH>) is "shorthand" for: while (defined( $_=<FH>)), and the defined can sometimes be important if your last entry in a file is a 0 without \n afterwards. And normally, I don't want to miss a single zero at the end which could even happen with <> if you pipe in a file.
Good worry, but no need to lose sleep since Perl's behaviour has been adapted to do the right thing in the real world a while ago.
$ perl -MO=Deparse -e'1 while my $line = <>;' '???' while defined(my $line = <ARGV>); -e syntax OK $ perl -v This is perl, v5.6.1 built for i386-linux
I'm not sure exactly when it changed; perldoc perldelta for 5.6.1 doesn't mention it and I can't seem to find any mention in older versions of the POD found on perldoc.com either. Of course even on older Perls, you can use the my construct by simply adding the defined yourself..
while(defined(my $line = <>)){ # ... }

Makeshifts last the longest.


In reply to Re^2: Style, style, style by Aristotle
in thread Style, style, style by Juerd

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 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
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2021-06-24 10:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (125 votes). Check out past polls.

    Notices?