package Mine::Openview::opcmsg; use strict; use warnings; sub new { my $class = shift; my %params = @_; my $self = \%params; return bless $self, $class; } sub send { my $self = shift; # Setup arguments for opcmsg command. If the syntax # changes this is were you'll apply the changes. my $cmd = "opcmsg". " msg_text=".$self->{cmd}. " application=".$self{app}. " object=".$self->{obj}. " severity=".$self->{sev}. " msg_grp=".$self->{msgg}. " service_id=".$self->{ser}; return $cmd; } 1;
That would allow you to access the module variables like this:
..in module.. sub somefunction { my $self = shift; my $msg = $self->{msg}; }
I.e. it makes the hash %params which contains your parameters the basis for the object you're creating - it then contains all the values you've passed to the constructor.
--------------------------------------------------------------
"If there is such a phenomenon as absolute evil, it consists in treating another human being as a thing."
John Brunner, "The Shockwave Rider".
In reply to Re: Help with building modules
by g0n
in thread Help with building modules
by neilwatson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |