http://qs321.pair.com?node_id=30417


in reply to Win32::MemoryInfo

Cool.

One things I hate about Win32::API is its encouragement of creating strings from barewords. Drop the no strict "subs" and just do:

my $GlobalMemoryStatus ||= Win32::API->new( "kernel32", "GlobalMemoryStatus", ["P"], "V" ) or return;

I would not export anything nor have a separate routine and simply pass in the format to the routine as "B" (or nothing) for bytes, "K" for 1024, "M" for 1024*1024, or "G" for 1024**3. I would just drop the whole ceil stuff. What is wrong with saying you have 2.4MB of memory available? And put the single remaining exportable symbol into @EXPORT_OK not @EXPORT.

And the only major change: You have enough parameters being returned that I'd return them as a hash reference so I don't have to keep looking up what order those values come back in. For extra credit, let the user specify a list of parameters that they are interested in. Return a list of just those values or return the hash ref if no particular parameters were requested.

        - tye (but my friends call me "Tye")