in reply to scope of variables in a sub

Policy:perms REGEXP:image.([0-9]+).([0-9]+) OWNER:ANY GROUP:ANY VSNAME:dyn{2}{1} VSOWNER:root Use of uninitialized value $vsowner in concatenation (.) or string at +./getconf line 395. foo

The first time through the outer foreach loop /filter_name =\s+(.*)/ matches so it goes through the inner loop where /REGEXP =\s+(.*)/ and then /OWNER =\s+(.*)/ and then /GROUP =\s+(.*)/ match in turn.

The second time through the outer foreach loop /vs_name =\s+(.*)/ matches.

The third time through the outer foreach loop /vs_owner =\s+(.*)/ matches.

Because of the way you capture the variable data, if the outer loop iterates again the regular expressions will not match and the variable $vsowner will cleared (set to undef).

Change each if/elsif expression from:

if ( ( $variable ) = /pattern (.*)/ ) {

To:

if ( /pattern (.*)/ ) { $variable = $1;