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

Curtis Call ccall at juniper.net
Tue Mar 8 18:28:24 EST 2011


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