I change the code by using array, but i don't know how to pass an array to a
bundle.
The code below took effect, but it used a global array which i do not like.

bundle agent replace()
{
    vars:
        "replacement[This]" string => "111";
        "replacement[is]" string => "222";
        "replacement[test]" string => "333";
    files:
        "/test/test.txt"
        edit_line => replace_lines("@(replace.patterns)");
}

bundle edit_line replace_lines(patterns)
{
    replace_patterns:
        "$(patterns)"
             replace_with => with("$(replace.replacement[$(patterns)])");

}

body replace_with with(str)
{
    replace_value => "$(str)";
    occurrences => "all";
}

2010/1/5 Daniel Dehennin <daniel.dehen...@baby-gnu.org>

> Le 5969 Septembre 1993, flex a envoyé:
> > Is there anybody can help me ?
>
> May be using an associative array ?
>
> --8<---------------cut here---------------start------------->8---
> bundle agent replace()
> {
> vars:
>    "replacement[This] string => "111";
>    "replacement[is]   string => "222";
>    "replacement[test] string => "333";
>
>    "patterns" slist => getindices("replacement");
> }
> --8<---------------cut here---------------end--------------->8---
>
> I hope it will help you.
>
> Regards.
> --
> Daniel Dehennin
> Récupérer ma clef GPG:
> gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1
>
> _______________________________________________
> Help-cfengine mailing list
> Help-cfengine@cfengine.org
> https://cfengine.org/mailman/listinfo/help-cfengine
>
>


-- 
System Administrator, Focus on System Management and Basic Development
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to