in reply to Re: Re: Re: Can this If/Else be condensed into a 1 liner with a trailing If?
in thread Can this If/Else be condensed into a 1 liner with a trailing If?

Actually, not quite... remember
print "$in wasn't a number!";input() unless $in =~ /\d/; # is the same as print "$in wasn't a number!"; input() unless $in =~ /\d/; # what you want is print("$in wasn't a number!"),input() unless $in =~ /\d/;
See, with the comma, the unless contains the print and the input, with the ; it only contains the input(), and I'm not sure what will be returned in that case, so I would probably do...
print("$in wasn't a number!"),return input() unless $in =~ /\d/;
Just to be safe. (It might work properly anyway, I'd have to test)

It should return $in otherwise... I think... my rule of thumb usually is, if I am not sure what will be returned, I use a return. I usually only leave out the return when my value is on the actual last line of the subroutine. Can save headaches... :)

                - Ant
                - Some of my best work - Fish Dinner