# AliceUtils.pm package AliceUtils; # Tell Exporter::Shiny which functions to make available to others: use Exporter::Shiny 'safe_filename'; sub safe_filename { my $string = shift; $string =~ s{\W}{}g; $string = "untitled" if !$string; return $string; } 1; # BobUtils.pm package BobUtils; # Tell AliceUtils which functions we want from it: use AliceUtils 'safe_filename'; # Tell Exporter::Shiny which functions to make available to others: use Exporter::Shiny 'save_data'; sub save_data { my ( $filename, $data ) = @_; my $safe_filename = safe_filename( $filename ) . ".txt"; open my $fh, '>', $safe_filename or die; print $fh $data or die; close $fh or die; return $safe_filename; } 1; # example.pl use AliceUtils; use BobUtils 'save_data'; save_data( "my file", "Hello world!\n" );