in reply to Get the $main value when use local

You can't:
local and my are different
local does not work the same way as my. In particular, it doesn't create private variables. Variables declared local remain global. Instead, Perl assigns a temporary value to the variable, and then restores the old value when the variable goes out of scope.

"We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise." - Larry Wall.