| Jens Thoms Toerring 2007-01-26, 7:20 am |
| Rainer Weikusat <rainer.weikusat@sncag.com> wrote:
> jt@toerring.de (Jens Thoms Toerring) writes:
[vbcol=seagreen]
> It's weirder than that: On the system where I tried (Debian Stable/
> Linux 2.6.20-rc3), the first script below prints 1024 after having
> done a getrlimit-call and the second 131072, apparently pulling
> the number out of some hat.
> ---------------
> use POSIX;
> printf "%s\n", POSIX::sysconf(POSIX::_SC_OPEN_MAX);
> ---------------
> ---------------
> use POSIX qw(sysconf);
> printf "%s\n", POSIX::sysconf(POSIX::_SC_OPEN_MAX);
> ---------------
You're supposed to put an ampersand in front of the "constant":
POSIX::sysconf(&POSIX::_SC_OPEN_MAX)
If you do so the result in both cases is 1024 on my machine (which
is also what I get from 'ulimit -n'), otherwise I also get 1024 for
the first and 131072 for the second version. The reason seems to be
that all "constants" are actually constant functions (as I only found
mentioned in the Camel book). So if you import everything by default
(i.e. without the 'qw(sysconf)' or if you import both sysconf and
_SC_OPEN_MAX then your program knows that _SC_OPEN_MAX is actually
a (constant) function and treats it as such. Admittedly, that's all
a bit weird;-)
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
|