http://qs1969.pair.com?node_id=615126


in reply to Reopen a class, add methods ?

Either way works fine, though I prefer not to have multiple packages in one file. But that's just a matter of style.

However, it seems to me that defining a derived class would be a more sensible approach. If you don't want to make an actual module, you can define the class inline with your script.

The following is untested but demonstrates the idea.

#!/usr/bin/perl use strict; use Tk; use Tk::Label; use Tk::HList; package Rudif::Tk::HList; @Rudif::Tk::HList::ISA = ( 'Tk::HList' ); sub addrow { my ( $self, $row, $text ) = @_; $self->add($row); $self->itemCreate( $row, 0, -text => $text ); } sub updaterow { my ( $self, $row, $text ) = @_; $self->itemConfigure( $row, 0, -text => $text ); } package main; # your stuff here