Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Sys::IP

by idnopheq (Chaplain)
on Apr 04, 2001 at 14:32 UTC ( #69609=note: print w/ replies, xml ) Need Help??

in reply to Sys::IP

I tested this on a RedHat 7 box w/ 5.6.0. It failed with

Undefined subroutine &Sys::IP::SUPPORTED called at /usr/lib/perl5/site_perl/5.6.0/Sys/ line 27. BEGIN failed--compilation aborted at /usr/lib/perl5/site_perl/5.6.0/Sys/ line 28. Compilation failed in require at ./ line 5. BEGIN failed--compilation aborted at ./ line 5.

I think the BEGIN block doesn't like looking for a sub not included in the block. So, I tested my theory with the following adjustment:

#--------------------------------------------------------------------- +-------# #we want to die if a system isn't explicitly supported BEGIN { #these are the os's that are supported at this time my @Supported = ( 'openbsd', 'freebsd', 'linux', 'irix', 'solaris', 'darwin', 'MSWin32' ); grep /$^O/, @Supported or die "$^O isn't supported by Sys:IP yet.\n"; }

I've been up all night, so this could be made better, but it works. Here is my test code:

#!/usr/bin/perl -w #-*-perl-*- use strict; use Sys::IP; use diagnostics; my $ip = ip(); my @ips = ips(); print $ip , "\n"; foreach ( @ips ) { print $_ , "\n"; }

BTW, MSWin32 uses 'ipconfig /all' for the type of data you need. I think it sits in %SystemRoot%/system32 on NT/2k and %SystemRoot%/command on 98/ME, but I could be wrong. By default, if networking is installed, ipconfig should reside in the PATH env var. I'll check it for you when I get in to work.


Comment on Re: Sys::IP
Select or Download Code
Replies are listed 'Best First'.
Re: Re: Sys::IP
by BlueLines (Hermit) on Apr 05, 2001 at 14:27 UTC
    heh, i _knew_ that BEGIN foolishness wasn't going to do what i thought it would. I was constantly doing the following:
    nooky:~$ sudo cp /usr/lib/perl5/5.6.0/i386-linux/Sys/ nooky:~$ perl -MSys::IP -e 'print ips()'
    over and over again. I must not have tested the BEGIN version (I originally did what you did). But thanks for the feedback. I'm fixing that, and I'll try the new Win32 stuff, and if all goes well, I'll ship it off to CPAN.


    Disclaimer: This post may contain inaccurate information, be habit forming, cause atomic warfare between peaceful countries, speed up male pattern baldness, interfere with your cable reception, exile you from certain third world countries, ruin your marriage, and generally spoil your day. No batteries included, no strings attached, your mileage may vary.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://69609]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2015-11-26 19:02 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (706 votes), past polls