use lib 'path/to/the/modules'; # The example module could be path/to/the/modules/NameOfTheProject/SomeModule.pm #### use strict; package NameOfTheProject::SomeModule; sub some_function { # put sane code here return 123; } 1; #### use NameOfTheProject::SomeModule; print NameOfTheProject::SomeModule::some_function(); # prints 123 #### use base 'Exporter'; our @EXPORT_OK = ('some_function'); #### use NameOfTheProject::SomeModule ('some_function'); print some_function(); # prints 123 #### # This is config.pl mirror => 'http://www.nl.example.com/mirror', path => '/var/www/example', skip_files => [ 'png', 'gif', 'jpg' ], #### # This is script.pl use strict; my %config = do 'config.pl'; chdir $config{path}; ... #### use strict; package Acme::Include; use base 'Exporter'; use File::Slurp (); our @EXPORT = 'include'; { package DB; # The sub's name is fully qualified to avoid getting a B::Include sub Acme::Include::include ($) { my ($filename) = @_; my $code = qq[#line 1 "$filename"\n] . File::Slurp::read_file($filename); eval $code; } } 1; #### # This is foo.pl use strict; use Acme::Include; my $lexical = 'set in foo.pl'; include 'bar.pl'; print $lexical; # Should print: set in bar.pl #### # This is bar.pl use strict; $lexical = 'set in bar.pl'; # There is no "my" here, because that would create a *new* lexical # variable, hiding the existing one.