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

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
while (<>) { ... } or while (my $line = <>) { ... }?

The implicit $_, unless spelling things out makes it clearer.

-w or use warnings;?

use warnings; whenever the Perl version lets me.

sub CONSTANT () { ... } or use constant CONSTANT => ...;?

The latter in general, to avoid confusion about intended use.

my ($foo, $bar) = @_; or my $foo = shift; my $bar = shift;?

Option 1, unless there a $self I'll shift of, I'm using default values, or there's a hash being passed by value.

for (@array) { ... } or foreach (@array) { ... }?

Both, depending on what I'm doing. It could even be .... for (@array);.

print 'foo'; or print('foo');?

No parens please, I'll put them in on the rare occasion I need them.

'simple string'; or "simple string"?

Interpolated unless I explicity don't want it.

glob '*' or <*>?

Depending on who will see the code. A lot of people don't know about <*>.

readline *FOO or <FOO>?


for (keys %foo) { $_ and $foo{$_} } or while (my ($key, $value) = each %foo) { $key and $value }?

That would be door no. 1, please, unless %foo is tied to something like a database, to avoid getting Perl all cranky. :-)

— Arien

In reply to Re: Style, style, style by Arien
in thread Style, style, style by Juerd

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?

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2021-06-22 15:10 GMT
Find Nodes?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)

    Results (106 votes). Check out past polls.