Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

RE: RE (tilly) 2: Regarding style

by merlyn (Sage)
on Oct 25, 2000 at 03:34 UTC ( [id://38253]=note: print w/replies, xml ) Need Help??


in reply to RE (tilly) 2: Regarding style
in thread Regarding style

Continuing on the diamond theme, I usually flag "dangerous" anything during code reviews that look like:
print "Some prompt? "; $input = <>;
Why? Because that program works fine when you run it without command-line arguments. But what happens when some other part of the program needs a command arg for a toggle or something? Oops!

And saying "well, sometimes I want to get stuff from files instead of STDIN" doesn't fly, because then you get the extra prompts!

For me, the only proper combination is:

  • print "..."; $input = <STDIN>;, or
  • $input = <>;

In other words, if you're interacting, use the explicit filehandle. Otherwise, suck from diamond.

-- Randal L. Schwartz, Perl hacker

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-04-19 05:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found