Ask Your Question
0

define multiple variables under a case statement

asked 2014-11-10 03:43:57 -0500

Yeayu gravatar image

Hello all,

I am trying to define different folder pathes (variables) depending on the system architecture:

class test{
         case $::architecture {
         'x86': {$path1 = "C:\\Program Files\\path1"}
         'x64': {$path1 = "C:\\Program Files (x86)\\path1"}
    }

The code listed above works as expected, however i am strugling to find a way of defining different variables under the same x86, x64 stament. Something like this:

class test{
         case $::architecture {
         'x86': {$path1 = "C:\\Program Files\\path1", $path2 = "C:\\foo\\test1"}
         'x64': {$path1 = "C:\\Program Files (x86)\\path1", $path2 = "C:\\foo (x86)\\test1"}
    }

any help?

Thanks in advance.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2014-11-10 14:51:07 -0500

lupin gravatar image

How about this?

class test {
  case $::architecture {
    'x86_64': {
      $path1 = ['c:\\program\\files', 'c:\\foo\path1']
      $path2 = 'c:\\foo\path2'
    }
    'x86': {
      $path2 = 'c:\\foo (x86)\path3'
      $path1 = ['c:\\program (x86)\\files', 'c:\\foo (x86)\path1']
    }
  }
}
edit flag offensive delete link more
0

answered 2014-11-10 17:52:27 -0500

Yeayu gravatar image

updated 2014-11-10 17:53:12 -0500

Well... one of my colleagues came out with the solution, using arrays:

class test{
     case $::architecture {
     'x86': {$path_array = ["C:\\Program Files\\path1", "C:\\foo\\test1"]}
     'x64': {$path_array = ["C:\\Program Files(x86)\\path1", "C:\\foo2\\test1"]}
}

And then, access to each of the paths as follows:

   $path_array [0]
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-11-10 03:43:57 -0500

Seen: 3,572 times

Last updated: Nov 10 '14