in reply to problem ..related to perl package concept

can anyone explain why

You're putting a sub into a different package, but you're not in that package. If you want that, use something like this:

#!/usr/bin/perl -w $var='one'; $mypackage::var='two'; { package mypackage; sub func { print "my \$var is $var\n"; } } mypackage::func(); __END__ Name "main::var" used only once: possible typo at foo.pl line 3. my $var is two