if ( not( $ref ) ) { print "No results\n"; } else { # code to print results }