Discussion:
[Puppet Users] quick split function question
Matt
2009-10-08 15:40:28 UTC
Permalink
With 0.25 we can use the split function to parse a string in to an array.

In puppet how can I reference a single element of that array?

$temp = "1,2,3,4"

Then i'd lilke to do :

$val = split($temp,',')[0]

Thanks,

Matt

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet-***@googlegroups.com
To unsubscribe from this group, send email to puppet-users+***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Trevor Vaughan
2009-10-08 18:16:04 UTC
Permalink
Heh...PERL.

temp = '1,2,3,4'
val = temp.split(',')[0]

Trevor
Post by Matt
With 0.25 we can use the split function to parse a string in to an array.
In puppet how can I reference a single element of that array?
$temp = "1,2,3,4"
$val = split($temp,',')[0]
Thanks,
Matt
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet-***@googlegroups.com
To unsubscribe from this group, send email to puppet-users+***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---
R.I.Pienaar
2009-10-08 18:18:10 UTC
Permalink
hello,
Post by Trevor Vaughan
Heh...PERL.
temp = '1,2,3,4'
val = temp.split(',')[0]
I suspect he wants to use the new split() parser function available in manifests and not in a template.

In that case, no you cannot reference a specific array member in the puppet DSL at present.
Post by Trevor Vaughan
Post by Matt
In puppet how can I reference a single element of that array?
$temp = "1,2,3,4"
$val = split($temp,',')[0]
--
R.I.Pienaar

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet-***@googlegroups.com
To unsubscribe from this group, send email to puppet-users+***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Trevor Vaughan
2009-10-08 18:50:46 UTC
Permalink
$temp = '1,2,3,4'
$val = inline_template(<%= temp.split(',')[0] %>)

Trevor
Post by R.I.Pienaar
hello,
Post by Trevor Vaughan
Heh...PERL.
temp = '1,2,3,4'
val = temp.split(',')[0]
I suspect he wants to use the new split() parser function available in manifests and not in a template.
In that case, no you cannot reference a specific array member in the puppet DSL at present.
Post by Trevor Vaughan
Post by Matt
In puppet how can I reference a single element of that array?
$temp = "1,2,3,4"
$val = split($temp,',')[0]
--
R.I.Pienaar
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet-***@googlegroups.com
To unsubscribe from this group, send email to puppet-users+***@googlegroups.com
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Loading...