Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: strange behaviour in perl ..please explain

by puudeli (Pilgrim)
on Jan 23, 2009 at 10:16 UTC ( [id://738423]=note: print w/replies, xml ) Need Help??


in reply to strange behaviour in perl ..please explain

  1. print can take a list as an argument, thus the return value (1 ie. true) of the print"no" gets printed (comma is a list separator).
  2. exit gets evaluated and your script exits.
  3. The last part of your statement is evaluated first, that means that if( $var ) exit is executed first and it exits.

Update: corrected #2, thanks ikegami

--
seek $her, $from, $everywhere if exists $true{love};

Replies are listed 'Best First'.
Re^2: strange behaviour in perl ..please explain
by ikegami (Patriarch) on Jan 23, 2009 at 15:30 UTC

    exit evaluates given expression, your print statement in this case and exits.

    No. exit is evaluated with no arguments in all of the OP's snippets.

    print"yes",exit ,print"no" if ($var)

    is the same as

    print( "yes", exit(), print("no") ) if ($var)

    That's because

    print( "yes", exit( , print("no") ) ) if ($var)

    is illegal.

      Ah, I stand corrected, I missed the comma :-)

      --
      seek $her, $from, $everywhere if exists $true{love};

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-25 13:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found