Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: Code Blocks

by Ronnie (Scribe)
on Jul 27, 2006 at 13:11 UTC ( [id://564064]=note: print w/replies, xml ) Need Help??


in reply to Re: Code Blocks
in thread Code Blocks

Sorry but I assumed from the sub name - toytown - that you'd work out that it's not production code just a small example of what I was trying to do. Thanks for the help, I've found 2 working options from the responses that I've had. Cheers, Ronnie

Replies are listed 'Best First'.
Re^3: Code Blocks
by GrandFather (Saint) on Jul 27, 2006 at 19:53 UTC

    Posting a short clear represntative sample is to be appluded (or up voted anyway). Posting something untidy and obscure that can not be easily run and doesn't seem to illustrate the issue at hand will not get you the best posible help (the down votes are incedental in that case).

    Although it's not clear from your original post, it may be that you were trying to execute several statements when something failed. There are ways to do that as others have mentioned (perhaps omitting the comma operator - see below). But much better is to use an if/else.

    Using an if makes it clear that a test is being made and what gets executed as a result of the test. It is easy to add stuff to be executed for the fail or success case without a lot of mental exercise. The code is easier to understand and easier to maintain.

    Oh, and the comma operator? I don't recommend it but:

    use warnings; use strict ; 0 or (print 'this'), (print " and that\n");

    DWIM is Perl's answer to Gödel

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2024-04-18 11:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found