Currently, your "MyApp.pm" file is both your application class and your context class (NB: this is expected to change in 5.8000). We've been slowing suggesting that people move things out of th context/app class so as not to pollute it with an abundance of mehods which may occasionally have unwanted consequences -- for example "login : Global {}" conflicting with the Authentication plugin's login() method.
This tip is broken into two parts:
package Catalyst::Plugin::Foo;
use Foo;
sub foo {
my( $c, @rest ) = @_;
return Foo->new( @rest );
}
You should reconsider. Either use the module directly, or make a controller base class. That should handle most cases.
package MyApp;
use Digest::MD5 qw(md5_hex); # MyApp now has the md5_hex method
sub foo {
# ...
return md5_hex( $string );
}
after:
package MyApp;
use Digest::MD5 (); # no imports
sub foo {
# ...
return Digest::MD5::md5_hex( $string );
}
If you want a quick-n-easy cleanup, try namespace::clean.