| From | Sent On | Attachments |
|---|---|---|
| Luke Kanies | Aug 23, 2005 5:00 pm |
| Subject: | [Puppet-dev] planned case statement syntax | |
|---|---|---|
| From: | Luke Kanies (lu...@madstop.com) | |
| Date: | Aug 23, 2005 5:00:38 pm | |
| List: | com.madstop.puppet-dev | |
I'm obviating the existing if/then/else functionality for this proposed case statement syntax:
# $operatingsystem is set by puppet
case $operatingsystem { "SunOS": { file { "/etc/somefile": owner => root } } "FreeBSD": { file { "/etc/otherfile": owner => root } } "Linux": { case $distro { # also set by puppet "Debian": { file { "/etc/debfile": owner => root } } "Fedora": { file { "/etc/fedfile": owner => root } } } } }
Compare the case statement to a selector statement:
$value = $operatingsystem ? { "SunOS" => "sunvalue", "FreeBSD" => "bsdvalue", "Linux" => $distro ? { "Debian" => "debvalue", "Fedora" => "fedvalue" } }
The biggest differentiator between case statements and selectors is that selectors return values and case statements perform work.
It's worth noting that the functionality you see here is basically the limit of what I plan on providing in the first version -- compare copmlete strings against each other. As needs become more clear I'll be adding expressiveness, but I think this is good enough to start.
-- What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against? --Larry Wall in <1992...@netlabs.com>
--------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://config.sage.org





