http://www.perlmonks.org?node_id=761291


in reply to return Both ARRAY and SCALAR

Instead of doing what you're doing, you could just store everything in an array. Then for fields you know have only one value, just do:
my ($field) = $parser->get_values();
Not perfect, but probably cleaner than the approach you're trying to take. (Whether it's useful or not will depend on exactly how you're using this data, which you haven't explained).