in reply to scope of variables in a sub

You don't show us the input data, which leaves us speculating ...

My (weak) guess is you have an empty match setting $vsowner to undef at some point.

What happens if you change .* to .+ ?

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^2: scope of variables in a sub
by frontrange (Initiate) on Sep 23, 2020 at 23:32 UTC

    No difference, the data comes from a database and there are no empty records in the source, you can see the variables it populates, printed inside the foreach loop, and then untouched till it's printed outside the loop where it is uninitialized.