Old Site

This site is archived. I now update and maintain my blog here.

Perl, overriding and TeamSite

Quite a common TeamSite development task is to take an API call and extend the functionality.

Often the other consultants that I work with are surprised when I show them that Perl does inheritance just like big grown up OO languages so I think this is a tip worth writing about here.

The sample below shows how to extend the AddFile method of TeamSite::WFtask to log a warning when a certain number of files are attached (at around 700 files workflow external tasks break as Perl is limited to around 700 command line arguments).

package My::TeamSite::WFtask;

use strict;
use utf8;

# equivalent of 'extends'
use base qw(TeamSite::WFtask);

use constant MAX_ATTACHED_FILES => 600;

# Methods that exist in the base class are automatically overriden.
sub AddFile {

    my ($self, $vpath) = @_;

    my $currently_attached = scalar($self->GetFiles);
    if($currently_attached >= MAX_ATTACHED_FILES) {
        My::Logger::warn("Too many files!");

    # Call the base class method.



Finally: I'm aware that the "Too many arguments issue" can be removed by adding the following to iw.cfg:



Leave a comment