in reply to Is it a reference issue or what?

I can't make heads or tail of your design. What are you trying to do?

You pass to the constructor a value that shared by all objects of that class. That makes no sense.

The class is called Coles_Backup_Drive, but object of that class in no way represent anything of the kind. Or anything else. The objects only has one member ($$self), and it's never used.

Are the methods suppose to be static methods aka class methods? Everything is in in static attributes aka class attributes. If so, why do you create an object?

Replies are listed 'Best First'.
Re^2: Is it a reference issue or what?
by OzVegan (Acolyte) on Jan 28, 2010 at 07:23 UTC

    Yeah well, it's a work in progress. The class actually instantiates a Win32_Drive object. The global hash and array I will fix later to make them private. $$self->FreeSpace is used. It is a method of the Win32_Drive class that is blessed into the class

    So what I'm trying to do is bless the Win32_Drive class returned by a WMI query so I can add other methods to it.

    The CIM_Datafile collection ($file returned by WMI) is supposed to be of various .bak and .trn files found in that drive.

    Because the .trn files are on different drives to the .bak files I want multiple Backup_Drives that are holding their own collection of files. Then I can work out the calculations where they have to cross reference each other for information later.

    It's complicated.

      I doubt that reblessing a Win32::OLE object will work as you intend it to, because Win32::OLE objects live mainly in C/XS space. I recommend you aggregate the WMI object instead of trying to extend it, and delegate all unknown methods to the WMI object via AUTOLOAD:

      sub AUTOLOAD { my $self = shift; (my $meth = $AUTOLOAD) =~ s/.*::/; # Now call the method on the WMI object $self->{wmi}->$meth(@_); }

      The above method could be refined further to play with the stack so that all error messages point to the real caller instead of the reflection method, but for a first stab, this approach is OK.

        That's a cool idea! I'll try that. Thanks.