in reply to Encapsulate function and variables
For most practical purposes, you can treat a namespace exactly as if it were a hash.
sub capsule { my($capsule_name, $file) = @_; my $src = slurp $file; eval "package $capsule_name; \n#line 1\n$src" or die $@; } [...] capusle("Foo", "foo.pl"); print $Foo::{text};
An alternative is to load everything into a dummy package with a throwaway name, then to export everything out of it. Of course, both these proposals break if foo.pl switches namespaces itself, and that's hard to catch.
In Section
Seekers of Perl Wisdom