Hi, I have struggled for the whole afternoon trying to
code a perl object which also enable users to fill in
the its data member ( a hash of hash).See the purpose below. I cannot figure it out. Please help.
Class Purpose: I am using this class as a data
storage for the list of MSSQL DATABASE servers which
later one I will try to connect to then do some query
against, then verify those query results
basically, it does the following:
1. get a list of servers with credentials from other program and feed those into the object.. use default as fallback (should I?)
2. read in those data tying to that server
3. clients can add server
4. clients can delete server
5.clients can delete everything
clients here mean the users of the object
package myObject;
$VERSION = 1.00;
use strict;
use warnings;
use diagnostics;
use vars qw(@ISA);
@ISA = qw(Class::Singleton);
use Carp ();
$Carp::Verbose =1;
{
my %serverMap = (
default => {
ipaddress=127.0.0.1,
dsn=""default,
userid="sa",
password="password",
instance="instance"
},
);
sub new{
my ($self, %args) = @_;
my %array=();
%array = (%args); #?
my $self={};
return bless {$self};
}
sub printMe(){
my ($self) = @_;
while ( ($server, $credentials) = each $self->%serverMap) {
print "$server: ";
while ( ($credentials, $value) = each %$roles ) {
print "$credentials=$value ";
}
print "\n";
}
}
sub fillServerMap($){ <<<<< no idea how to input
my ($self) = @_;
for $server ( @_ ) {
push @ <<<-- NO IDEA how to do this
}
}
}
sub removeServerMap($){
my ($self) = @_;
$self->serverMap ={};
}
sub deleteServer($){
my ($self,$server)=@_;
delete $self->serverMap {$server};
}
1
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.