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


in reply to Joining if an array

I might be tempted to use the ternery operator, but usually for a non-trivial assignment (like a join) I'd avoid it as it just gets messy. I'd probably do:
my $in; if (ref $scalar eq 'ARRAY') { $in = join(",",@$scalar); } else { $in = $scalar; }
Not short, but pretty clear in what I mean (hopefully).