Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Climbing Mt. Perlcritic -- Switch statements

by graff (Chancellor)
on Mar 25, 2009 at 22:59 UTC ( [id://753282]=note: print w/replies, xml ) Need Help??


in reply to Climbing Mt. Perlcritic -- Switch statements

First, I don't see the original version and the "switch" version in the OP code as being equivalent -- they don't do the same thing. Maybe you've tested and confirmed that your usage of the "switch" statement gives the same result as the non-switch version, in the sense that both case blocks can operate on the same string (if it happens to match both "filename=..." and "go"). (If I were using "switch", which I don't, that's something I'd want to test.) But it's still true that the non-switch version will only do @batch = () when you match /go/, whereas the switch version does that in every instance, no matter what; I don't know if that's a problem, but I would worry about it.

Apart from that, I would strongly advise against modifying code logic just to get a few points of improvement on someone else's idea of a "complexity/simplicity" score. (And as others have said, I would avoid using the switch module.)

You only should modify your coding logic or syntax if it's doing something wrong or if, when you try to read it, you find yourself struggling to understand what it's really doing (and/or what it's supposed to be doing). But if you can read it and it makes sense -- and if it works as intended -- it ain't broke, so don't "fix" it.

(updated first and last paragraphs to try making them clearer)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://753282]
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 00:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found