jg has asked for the wisdom of the Perl Monks concerning the following question:

Sometimes a whole package is too big just for some constant values, because it just consume the memory without use of any other values. especially for a long-time-running program.

So, I just try code like following..

# I just want to know WNOHANG from sys_wait_h ... [-; our $WNOHANG_VALUE ||= `$^X -MPOSIX=:sys_wait_h -e "print WNOHANG;"`; sub WNOHANG () { $WNOHANG_VALUE }

Is there any other way to do this?
Btw, I just want to know her thought like this..
not from after all the long and rediculus conversation.

Replies are listed 'Best First'.
Re: Get just constant from a package.
by JavaFan (Canon) on May 14, 2010 at 14:41 UTC
    Is there any other way to do this?
    Sure, you could hardcode the value. If it's a program that needs to run on multiple platforms, with different values for WNOHANG, you could make a switch on the supported platforms. Or determine the value when you install the program/module.
      Or determine the value when you install the program/module.
      This might be helpful for my case. I haven't written a module which needs some installer, though.
      Maybe I should look some modules from CPAN.. or just use some regular expression to that?