Ask a Question related to PERL Miscellaneous, Design and Development.

  1. #1

    Default Creating objects

    Hello,

    I am using Perl to access the Windows management interface to query
    information on some Windows boxes through the Win32::OLE module. I am
    on Windows 2000 Professional SP4 using ActivePerl 5.8. I wanted to
    create a cleaner interface to this information by trying the following
    code:

    # ****************************************
    # PACKAGE
    # ****************************************
    package WMI;
    use Win32::OLE qw(in);

    sub new{
    my $host = @_[1];
    my $WMI = Win32::OLE->GetObject("winmgmts://$host");
    my $class = shift;
    my $self = { WMI => $WMI };
    bless($self, $class);
    return $self;
    }

    sub getServices{
    my $self = shift;
    my $WMI = $self->{WMI};
    my $set = $WMI->InstancesOf("Win32_Service");
    foreach(in($set)){
    print "$_->{Name}\n";
    }
    }

    1;
    # ***********************************************

    # ***********************************************
    # Sample Code which successfully prints out a list of running
    services.
    # ***********************************************
    #!C:/perl/bin/perl

    use strict;
    use WMI;

    my $WMI = WMI->new("localhost");
    $WMI->getServices();
    # ************************************************

    So my question now is, is this a silly way to do this by taking an
    object and creating another layer over it like I've done? Your
    comments are greatly appreciated.

    Thanks,

    brice
    brice Guest

  2. Similar Questions and Discussions

    1. Creating Acrobat objects with LotusScript
      We have been automating Acrobat 6 with LotusScript (Notes 6.0.3) for some time, and are now upgrading Acrobat. The OLE class object reference for...
    2. DCOM Errors when creating COM Objects in IIS
      Hi all, I'm having a few problems creating COM objects in IIS. The issue only seems to affect a couple of our own custom COM objects. The COM...
    3. Creating COM objects remotely
      I am trying to create a cfobject that will inevitably create a Word Document, and after reading the materials have decided its probably not a good...
    4. Problem creating objects not as dbo
      I have a problem with people logging on as one user, but sql server keeps changing the owner to dbo. Sometimes the owner name will be their loggin...
    5. Handle leak when creating COM objects from ASP?
      Hi Leo I am experiencing the same problem (also windows 2000 server sp3). Do you have any further feedback? Alternatively, has this been...
  3. #2

    Default Re: Creating objects

    On 26 Aug 2003 06:02:13 -0700
    [email]bricemason@hotmail.com[/email] (brice) wrote:
    > So my question now is, is this a silly way to do this by taking an
    > object and creating another layer over it like I've done? Your
    > comments are greatly appreciated.
    Define what you mean by "silly". I'm of the opinion that, if it's
    going to aid in producing code latter on, then it's not "silly" - it's
    smart. It's that OO thing again.

    Other may have opinions on this, but that's mine to offer.

    --
    Jim
    James Willmore Guest

  4. #3

    Default Re: Creating objects

    James Willmore <jwillmore@cyberia.com> wrote in message news:<20030826150901.2f38ecd7.jwillmore@cyberia.co m>...
    >
    > Define what you mean by "silly". I'm of the opinion that, if it's
    > going to aid in producing code latter on, then it's not "silly" - it's
    > smart. It's that OO thing again.
    >
    > Other may have opinions on this, but that's mine to offer.
    Thanks for your response, I feel the same way. I know this will help
    me in the future grabbing this information from my Windows boxes.

    brice
    brice Guest

  5. #4

    Default Creating objects

    Hi,

    let us say there is Class A.
    In the constructor of this class I create an Object B of Class B.

    Now what is the difference between these two ?

    this->B = new B;

    and

    B = new B;


    Thank you very much!

    Wenmaster
    Webmaster Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139