quick split function question

2,315 views
Skip to first unread message

Matt

unread,
Oct 8, 2009, 11:40:28 AM10/8/09
to puppet...@googlegroups.com
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

Trevor Vaughan

unread,
Oct 8, 2009, 2:16:04 PM10/8/09
to puppet...@googlegroups.com
Heh...PERL.

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

Trevor

R.I.Pienaar

unread,
Oct 8, 2009, 2:18:10 PM10/8/09
to puppet...@googlegroups.com
hello,

----- "Trevor Vaughan" <peiri...@gmail.com> wrote:

> 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.

> > 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]


--
R.I.Pienaar

Trevor Vaughan

unread,
Oct 8, 2009, 2:50:46 PM10/8/09
to puppet...@googlegroups.com
$temp = '1,2,3,4'
$val = inline_template(<%= temp.split(',')[0] %>)

Trevor
Reply all
Reply to author
Forward
0 new messages