Q:

why naked block can not access out scope variable and function if packaged?

I want to define a class and test with is in naked block like this:
use Test::More tests => 1;

{
    package Foofle;
    use parent qw(Animal);
    sub sound { 'foof' }

    is(
        Foofle->speak,
        "A Foofle goes foof!\n",
        "An Animal subclass does the right thing"
    );
}

I got error Undefined subroutine &Foofle::is called at t/Animal.t, so if I add
use Test::More;

in naked block, then it runs ok.
Or I move is outside of naked block, 
use Test::More tests => 1;

{
    package Foofle;
    use parent qw(Animal);
    sub sound { 'foof' }
}

is(
    Foofle->speak,
    "A Foofle goes foof!\n",
    "An Animal subclass does the right thing"
);

it runs ok. But why naked block can not access out scope variable?

A:

Your use Test::More call imports the identifier is into the current package. In your first implementation, that means importing is into the package of your script, which is probably the main package. After that, every time you use is in the main package, Perl knows it should invoke Test::More::is.
Now, is stops being a synonym of Test::More::is as soon as you switch to a different package. In fact, you can try this: call is() in your naked block, but before you declare package Foofle. It should work just fine. It's not the naked block that is to blame; it's the fact that you're now in a different package.
One option is to use Test::More in your Foofle package as well, as you've tried already. The other is to use your original implementation, but invoke is with the fully qualified name: Test::More::is(Foofle->speak, "...", "...");.

A:

You are changing the package (or namespace) inside of your block. Each block in Perl creates a scope, and you can have scoped package changes.
At the beginning of your program, you are in the main package. You are useing Test::More in that package, so the is function gets imported into that package. That means, there is now a &main::is, which points to &Test::More::is.
Once you switch the package, Test::More has still been loaded, but the is function is not imported into the new package. That's why it complains that it cannot find &Foofle::is.
So it's really about the package, not the block.
Further reading: perlmod and package in perldoc.

