You need to show us where and how you call the &ComboBox subroutine. Follow Abigail-II's advice and read the appropriate man pages.

Rather than sit around and try and second guess what you're doing, I figured I could show you what is going on here. For a quick example of OO in Perl and what is going on here, save the following file as 'Counter.pm':

package Counter; use strict; use Carp; sub new { my ($class,$value) = @_; $value ||= 0; my $self = bless {}, $class; croak "Argument to constructor must be positive integer." if ! $self->_good_value( $value ); $self->{_value} = $value; return $self; } sub value { my $self = shift; $self->{_value} = $_[0] if $self->_good_value($_[0]); return $self->{_value}; } sub increment_value { my $self = shift; $self->{_value}++; } sub decrement_value { my $self = shift; $self->{_value}--; } sub _good_value { my ( $self, $value ) = @_; return 0 if ! defined $value; $value =~ /^\d+$/; } 1;

And then, in the same directory:

#!/usr/bin/perl -w use strict; BEGIN { unshift @INC, '.'; # add current directory to include path use Counter; } my $counter = Counter->new; print $counter->value, "\n"; $counter->increment_value; print $counter->value, "\n"; $counter->decrement_value; print $counter->value, "\n"; $counter->value(3); print $counter->value, "\n";

The above code is rather simple and not how I would really do it, but it gives you an idea of what is going on. If you don't understand it, you really need to learn Perl's OO system, as what I have presented is very basic.

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.


In reply to Re: Re: Re: Re: "this" variable? by Ovid
in thread "this" variable? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.