in reply to Re: Use of uninitialized value
in thread Use of uninitialized value

That can be fixed as follows by reordering the statememnts, or by wrapping the my (and therefore the sub) in a BEGIN block:

BEGIN { my $foo = "bar\n"; sub print_foo { print $foo; } }