in reply to Re^4: Merge 2 lines in 1 die statement
in thread Die statement with text & formatting of the user

That's because you are passing a list to print. For this list to be printed, its elements must be evaluated first. There's a exit call in that list, so that is done, and the print never gets executed. Consider
print "no rows\n", exit unless $rows; print "we seem to have rows.\n"; __END__

and

print "no rows\n" and exit unless $rows; print "we seem to have rows.\n"; __END__ no rows

update: as ikegami point out below, you are not passing a list to print - since you treat print as a function, and are passing in its arguments in parens. With the comma operator, you are still evalutaing a list, and in that list exit gets evaluated..

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Replies are listed 'Best First'.
Re^6: Merge 2 lines in 1 die statement
by ikegami (Patriarch) on Apr 28, 2007 at 15:44 UTC

    That's because you are passing a list to print.

    Unless he edited the code he posted, that's not true. His code has parens.

    print("no rows\n"), exit unless $rows; print "we seem to have rows.\n"; __END__ no rows
Re^6: Merge 2 lines in 1 die statement
by Nik (Initiate) on Apr 28, 2007 at 11:33 UTC
    Thank you now its clear to me!!
    Exit was evaluated but evaluation meant execution and the script dies prematurely witohut completely printed...

    Can you aslo answer on die statement i kses in same thread that both prints my error and displays its error too?

      That's because of the die on line 74.

      If your script dies, it passes a non-zero exit value to the invoking process - your web server. From the exit value it deduces something went wrong, so it sets a status of 500 - internal server error - and displays anything that was thrown out STDERR at the exit of your script - which is the error you want to have displayed.

      You surely do not want die there at line 74, but instead print a header with status 200 (if not already printed), print your error message to STDOUT, and exit after that.

      --shmem

      _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                    /\_¯/(q    /
      ----------------------------  \__(m.====·.(_("always off the crowd"))."·
      ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
        But i though local *STDERR = *STDOUT was supposed to redirect all errors to the default output which is the screen instead of the error.log. I still dont see why die thre print my erro message and also the default of dies as well....

        Perhaps you can make it more clear to me if it aint a bother.