http://www.perlmonks.org?node_id=120505


in reply to Net::Services

In light of the fact that this code requires socket capability, is there something I can add, say in a BEGIN block or via 'use' that would check that the system can support sockets at compile-time, as opposed to the run-time error message that one gets when the servent methods are used?

-----------------------------------------------------
Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
"I can see my house from here!"
It's not what you know, but knowing how to find it if you don't know that's important

Replies are listed 'Best First'.
Re:x2 Net::Services (use Config?)
by grinder (Bishop) on Oct 22, 2001 at 19:22 UTC

    Do you mean something along the lines of:

    use Config; BEGIN { die "You are socketless!\n" unless Config::config_vars(qw/d_socket/) eq 'define'; }

    If you need really specific socket capabilities there is any number of fine-grained tests you could perform. Randomly cutting and pasting from perldoc Config gives things like

    =over `d_getsbyname' From d_getsrvby.U: This variable conditionally defines the `HAS_GETSERVBYNAME' symbol, which indicates to the C program that the getservbyname() routine is available to look up services by their name. =cut

    Is this what you were looking for?

    --
    g r i n d e r