Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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 ( [id://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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-19 01:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found