in reply to Nested Ternary Operators

The ternary operator was designed (by Thompson and Ritchie, the inventors of C) to make this sort of thing simple.

Just use:

$ref = $hash_count ? \%hash : $array_count ? \@array : $ref_to_all_lines_in_file;
Note that no parentheses of any sort are necessary.