[j-nsp] Scripting - Redefining variables in For-each Loops

ben b benboyd.lists at gmail.com
Tue Mar 8 19:33:46 EST 2011


sweet thanks! works like a charm

On Tue, Mar 8, 2011 at 5:28 PM, Curtis Call <ccall at juniper.net> wrote:

> >
> > I have need to add the values calculated inside of a for-each loop.
> > Has anyone ever had to do that?
> >
> > Example of what I want
> > for-each ( $result ) {
> >      $a = . + 1;
> >      $b = $b + a;
> > }
> >
>
> You'll need to split this into multiple steps:
>
> var $values := {
>    for-each( $result ) {
>        <value> . + 1;
>    }
> }
>
> var $b = sum( $values/value );
>


More information about the juniper-nsp mailing list