in reply to print and return...

Why doesn't

return print "1\nError was $foo\n" if $foo;

work for you?

(darren)

Replies are listed 'Best First'.
Re: Re: print and return...
by ChemBoy (Priest) on Sep 28, 2001 at 09:23 UTC

    Well, it's not an equivalent statement--I don't know how precise Ant's requirements are, but assuming your print succeeds (which is probable, though not guaranteed), your code will return 1, and his will return undef.

    As I say, I don't know what the requirements of the function are, but if the code to which this sub is returning makes assumptions about the return value, this is not a good choice.

    That said, I like it. :-)



    If God had meant us to fly, he would *never* have given us the railroads.
        --Michael Flanders