[Arrray] grep -v

21 views
Skip to first unread message

Antidot SAS

unread,
Mar 19, 2012, 10:58:14 AM3/19/12
to puppet-users
Hi everyone,


I am trying to simulate the 'grep -v' behavior in an array:

Ex:
    vgrep(['aaa','bbb','ccc','aaaddd'], 'aaa')

Would return:

    ['bbb', 'ccc']

So I tried to use ruby to do it: normally the '-' operation should be enough (http://www.ruby-doc.org/core-1.9.3/Array.html#method-i-2D)
Here is the code:

puppet apply -e '
        $my_array=[ "test", "tt" ]
        $sub_test = [ "tt" ]
        $result= inline_template("<% my_array-sub_test %>")
        notice("$my_array")
        notice("$my_array - $sub_test")
        notice("$result")
'
notice: Scope(Class[main]): testtt
notice: Scope(Class[main]): testtt - tt
notice: Scope(Class[main]):
notice: Finished catalog run in 0.11 seconds

So it doesn't work this way any thoughts?

Regards,
JM

Krzysztof Wilczynski

unread,
Mar 19, 2012, 1:31:24 PM3/19/12
to puppet...@googlegroups.com
Hi,


So it doesn't work this way any thoughts?

Antidot SAS

unread,
Mar 19, 2012, 1:53:35 PM3/19/12
to puppet...@googlegroups.com
thx a lot... it helps

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/C-1pyK58Q6oJ.
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.

Krzysztof Wilczynski

unread,
Mar 19, 2012, 2:00:44 PM3/19/12
to puppet...@googlegroups.com
Hi,


thx a lot... it helps
[...]

I do hope that it fulfils your use case :)

KW

Krzysztof Wilczynski

unread,
Mar 19, 2012, 7:49:55 PM3/19/12
to puppet...@googlegroups.com
Hi,

Just wanted to let you know, that I have added "select.rb" to the "reject.rb", which is the opposite (to some extent).

I hope you find them useful :)

KW
Reply all
Reply to author
Forward
0 new messages