In Perl, the ref function returns an empty string when the variable passed to it is not a reference. Since $val is a plain string scalar, ref($val) evaluates to an empty string ('Empty Value', 596740) rather than throwing an error or returning a label like SCALAR.