Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Joining if an array

by Mutant (Priest)
on May 01, 2009 at 15:37 UTC ( #761317=note: print w/replies, xml ) Need Help??


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).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://761317]
help
Chatterbox?
NodeReaper tries to shade his eye-sockets with his hands

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2017-02-22 20:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (335 votes). Check out past polls.