in reply to Help with building modules
Pass your data to new() (the constructor) as a hash ref.
Your send method can then get the data from the object.#!/bin/perl5 use strict; use warnings; use Data::Dumper; #use lib '/home/nhwatson/lib/perl/'; use Mine::Openview::opcmsg; my $ovs = Mine::Openview::opcmsg->new( { msg => 'This is a test', app => 'Perl script', obj => 'Perl module', sev => 'warning', msgg => 'message group', ser => 'service ID', } ); #die Dumper $ovs; my $return = $ovs->send; print "\nreturn = " . $return . "\n";
output:package Mine::Openview::opcmsg; use strict; use warnings; sub new { my $class = shift; my $self = shift; return bless $self, $class; } sub send { my $self = shift; my $cmd = join "\n", "opcmsg", "msg_text = " . $self->{msg}, "application = " . $self->{app}, "object = " . $self->{obj}, "severity = ".$self->{sev}, "msg_grp = " . $self->{msgg}, "service_id = " . $self->{ser}; return $cmd; } 1;
As dorward suggested above, have a look at the docs.---------- Capture Output ---------- > "C:\Perl\bin\perl.exe" monk.pl return = opcmsg msg_text = This is a test application = Perl script object = Perl module severity = warning msg_grp = message group service_id = service ID > Terminated with exit code 0.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Help with building modules
by neilwatson (Priest) on Jan 26, 2006 at 15:39 UTC |