[Perl]  Use a Module / Object which is defined in the same file
I need to define some modules and use them all in the same file.  No, I can't change the requirement.

I would like to do something like the following:

    {
        package FooObj;
    
        sub new { ... }
    
        sub add_data { ... }
    }
    
    {
        package BarObj;
    
        use FooObj;
    
        sub new { 
            ... 
            # BarObj "has a" FooObj
            my $self = ( myFoo => FooObj->new() );
            ...
        }
    
        sub some_method { ... }
    }
    
    my $bar = BarObj->new();


However, this results in the message:

> Can't locate FooObj.pm in @INC ...  
> BEGIN failed...

How do I get this to work?
[Perl]  Use a Module / Object which is defined in the same file
===

I need to define some modules and use them all in the same file.  No, I can't change the requirement.

I would like to do something like the following:

    {
        package FooObj;
    
        sub new { ... }
    
        sub add_data { ... }
    }
    
    {
        package BarObj;
    
        use FooObj;
    
        sub new { 
            ... 
            # BarObj "has a" FooObj
            my $self = ( myFoo => FooObj->new() );
            ...
        }
    
        sub some_method { ... }
    }
    
    my $bar = BarObj->new();


However, this results in the message:

> Can't locate FooObj.pm in @INC ...  
> BEGIN failed...

How do I get this to work?