Hi,
Trying to write a generic function to deal with either arrays or strings.
Here's a cutdown version of what I'm writing highlighting the problem I
have.
All i'm trying to do is take 'server1.testing.com' from the variable
$server (the variable being either a string or an array) and assign it to
$bar, or assign 'server3.testing.com' if it isn't assigned at all.
<code>
# $server = 'server1.testing.com,server2.testing.com'
$server = [ 'server1.testing.com','server2.testing.com' ]
$fu = $server ? {
'' => 'server3.testing.com',
default => is_array($server) ? {
false => $server ? {
* default => split($server, ',')*
},
default => $server[0],
}
}
$bar = is_array($fu) ? {
false => $fu,
true => $fu[0],
}
</code>
Why can't I just split($server, ',')[0] ? Can I assign some of the result
of the split to the variable? Does someone else have an example of a more
elegant way to do this?
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.