Your mask subroutine is basically returning a copy of @base which is then assigned to @net. The technique has some performance issues, but should work fine as long as you only need to return a single list. Things get slightly more complicated when later you find that you need to return some other values from mask.