I guess I can divide it into two questions.
1.What if I want to do something below in one single step.
if($sth->fetchrow_array is empty /undef){
@parent = @default;
}
I tried something like this but failed.
@parent = $sth->fetchrow_array or @default;
## Problem is it assign undef if array1 is undef.
@parent = $sth->fetchrow_array || @default;
## problem is it assign scalar value to the parent if it's not undef
2.Below is the sample code. Why I get scalar value in second output?
@default = (2,3,4);
## First output
@parent = $sth->fetchrow_array or @default;
print @parent;
##Second output;
@parent = $sth->fetchrow_array || @default;
print @parent;
@parent = $sth->fetchrow_array or @default;It retuns undef If I do@parent = $sth->fetchrow_array || @default;it returns array count, not the array.orand||evaluate their LHS operand in scalar context.