Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Help with building modules

by g0n (Priest)
on Jan 26, 2006 at 15:20 UTC ( [id://525730]=note: print w/replies, xml ) Need Help??


in reply to Help with building modules

As a start, you could change your module like this:

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".

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://525730]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-23 06:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found