Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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).


Comment on Re: Joining if an array
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://761317]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (12)
As of 2014-09-17 20:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (99 votes), past polls