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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|