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};