I made a subroutine that returns a list of data in most circumstances, but sometimes returns an empty list (for "not found"). I want to do stuff if the return list is empty. I thought I could do this:
if(!searchsub($value))
{
#stuff
}
But, that is occasionally being evaluated as true for a nonempty list. (From my testing, this seems to be when the first list is found again. But that may be wrong.) The following is good:
my @arr=searchsub($value);
if(!@arr)
{
#stuff
}
Placing the return into an array first makes it work as I expect. How is the subroutine being evaluated, if not as a list? Also, is there a shortcut to avoid the extra array?