Why are you calling the sub twice?
In reply to Re^3: Perl variable scoping between functions by tobyink in thread Perl variable scoping between functions by Bryan882