Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: unless

by Bilbo (Pilgrim)
on Jun 25, 2003 at 16:20 UTC ( [id://268905]=note: print w/replies, xml ) Need Help??


in reply to multiple commands before unless ?

Try running this line:

print "Yes\n" && exit;

It probably doesn't do what you think it does. Now try this:

(print "Yes\n") && (exit);

The problem is, I think, that the first is interpreted as:

print ("Yes\n" && exit);

If the second operation (exit) is successful then this would print "1" for "true", except that since the second operation is exit it can't print anything because it's exited before it gets to the print statement.

Replies are listed 'Best First'.
Re: Re: unless
by fglock (Vicar) on Jun 25, 2003 at 16:38 UTC
    H:\>perl -e "print 'yes' and exit; print 'no' " yes H:\>perl -e "print 'yes' && exit; print 'no' " # nothing

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-24 01:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found