http://qs321.pair.com?node_id=420744


in reply to calling sub and returning value from the same line

Is error() returning a false value? That would cause the behavior you describe. Remember that <EXPR> and <EXPR> executes the second expression only if the first expression is true. To avoid this dependence on the return value of error() you could try
unless (open FH, ">$_[0]") { error($!, "not able to write to file $_[0]"); return undef; }

Replies are listed 'Best First'.
Re^2: calling sub and returning value from the same line
by dpuu (Chaplain) on Jan 09, 2005 at 21:00 UTC
    Another alternative is to replace the "and" operator with a comma:
    open FH, ">$file" or error("msg"), return undef;
    If you do this, you must use parentheses to call the "error" function.

    --Dave
    Opinions my own; statements of fact may be in error.