You never imported or exported the words
subroutine from the Flame::Text
package. A statement use Some::Module @args
is equivalent to:
BEGIN {
require Some::Module;
Some::Module->import(@args);
}
that is, the import
method is called with the specified arguments. This method would usually export various symbols from one package into the calling package.
Don't write your own import
, rather you can inherit one from the Exporter
module. This module is configured by storing exportable symbols in the @EXPORT_OK
global variable. So your code would become:
package Flame::Text;
use parent 'Exporter'; # inherit from Exporter
our @EXPORT_OK = qw/words/; # list all subs which you want to export upon request
sub words { ... }
Now, use Flame::Text 'words'
will work as expected.