[Catalyst] overload/override sub? (Session::PerUser)

Ash Berlin ash_cpan at firemirror.com
Mon Aug 6 21:42:28 GMT 2007

Fernan Aguero wrote:
> Hi,
> I'd like to overload (or would it be override?) the
> merge_session_to_user sub in
> Catalyst::Plugin::Session::PerUser to be able to guide the
> hash merge (i.e. create new hash value keys for conflicting
> keys).
> Now, where and how should I do the overriding? Excuse my ignorance
> ... but I've never done this and searching for 'Perl
> overload' always gets me to instructions on how to overload
> built-in operators ...
> Thanks in advance,
> Fernan

Redefine is the term in perl-lingua.

In MyApp.pm:

  no warnings 'redefine';

  sub merge_session_to_user {
    # your new sub

    # ...

    # To call the previous implementation if you should want it:
    # $self->NEXT::merge_session_to_user(@args);

The key thing to remember here is that all Cat plugins 'pollute' the $c
namespace, which isa Myapp.


More information about the Catalyst mailing list