Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: A matter of style: how to perform a simple action based on a simple condition?

by TomDLux (Vicar)
on Sep 26, 2010 at 04:25 UTC ( #862046=note: print w/ replies, xml ) Need Help??


in reply to A matter of style: how to perform a simple action based on a simple condition?

Using the and && is too much about the implementation. Use it in shell programs where you're grateful for a concise alternative to if{} blocks.

Use the if{} if you are going to do several things within the block, or if you are also going to use the else clause.

If what is being done is significant, the suffix if focuses on what is being done, rather than why. If the what is minor, the reason is still notable, while far more compact.

What I mean is, if you are processing a config file, you want to skip empty lines, ignoring space characters, and ignoring comment lines.

LINE: while ( my $line = <config> ) { chomp $line; next LINE unless $line =~ m{\S}; next LINE if $line =~ m{\a\s*\#}xms; # process line }

As Occam said: Entia non sunt multiplicanda praeter necessitatem.


Comment on Re: A matter of style: how to perform a simple action based on a simple condition?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2014-08-22 03:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (145 votes), past polls