Forum: CFEngine Help
Subject: Re: Access single list element
Author: sauer
Link to topic: https://cfengine.com/forum/read.php?3,23314,23351#msg-23351

neilhwatson Wrote:
-------------------------------------------------------
> Is there a way to access a given element within a
> list?  In Perl one might call
> $list[0] to get the first element. I tried a few
> variations of that in CF but
> nothing seemed to work.  I thought there was a
> thread about this some time ago
> but, I can seem to find it.

That'd be an array then, not a list. ;)  I'd probably solve the problem by 
doing something like
"listtoarray[$(list)]" string => "$(list)"
and then referencing elements from listtoarray.  And then I'd be compelled to 
say twelve Hail Marys afterwards to make up for copying the whole list to an 
array just to get to a single element which was already basically in an array. 
:)

There's probably something you could do with a combination of join, split, and 
grep as well if you feel more adventurous.

_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to