----- $name is constant inside sub ------ Use of uninitialized value $name in concatenation (.) or string at /tmp/test.pl line 17. red: Use of uninitialized value $name in concatenation (.) or string at /tmp/test.pl line 17. violet: ----- sub used inside loop that defined it ------ trying out red: trying out blue: trying out green: trying out yellow: trying out orange: trying out purple: trying out violet: ----- sub used outside of loop that assigned it ------ Use of uninitialized value $name in concatenation (.) or string at /tmp/test.pl line 52. red: green: violet: