On Sun Feb 17 16:37:05 2013, MMUSGROVE wrote:
Show quoted text> On Mon Jan 31 10:53:19 2011, PECO wrote:
> > Hello
> > First of all say thank you for your work with Win32::SystemInfo. It's a
> > great module.
> > I've an issue and may be you can help me.
> >
> > require Win32::SystemInfo;
> > my %mHash = (TotalPhys => 0, AvailPhys => 0);
> > if (Win32::SystemInfo::MemoryStatus(%mHash))
> > {
> > print $mHash{TotalPhys};
> > }
> >
> > Is a copy of your example, just changing "use" by "require". And I get:
> > Can't use string ("TotalPhys") as a HAS ref while "strictt refs" is use
> > at .... SystemInfo.pm line 231.
> >
> >
> > Thank you!
>
> There hasn't been an update made to this ticket so I thought I'd chime
> in with why this happens.
>
> Win32::SystemInfo uses prototypes for MemoryInfo and ProcessorInfo. In
> order for the prototypes to work correctly you should load the module
> with use. If you need or want to require it, then you'll need to add a
> forward declaration of the subroutines you want to call before you call
> them.
>
> require Win32::SystemInfo;
> my %mHash = (TotalPhys => 0, AvailPhys => 0);
> sub Win32::SystemInfo::MemoryStatus (\%;$);
> if ( Win32::SystemInfo::MemoryStatus(%mHash) )
> {
> print $mHash{TotalPhys};
> }
Thanks for commenting on this. I tried to recreate this, and I got no results at all - no errors,
either. Then I went down the rathole of use vs require but I couldn't figure out the issue there
either.