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")
|
---|
Replies are listed 'Best First'. | |
---|---|
(Guildenstern) REx2: Win32::MemoryInfo
by Guildenstern (Deacon) on Aug 31, 2000 at 17:51 UTC | |
by tye (Sage) on Aug 31, 2000 at 19:24 UTC | |
by Guildenstern (Deacon) on Aug 31, 2000 at 20:02 UTC | |
by tilly (Archbishop) on Sep 01, 2000 at 21:57 UTC | |
by Guildenstern (Deacon) on Sep 01, 2000 at 00:48 UTC |