If a machine has two network cards, which IP address do you want?

A machine doesn't have an IP addresss, a network card does.

Perhaps there are other ways to achieve what you want. I gather this is for Windows... perhaps you could just use an API call to get the name of the machine your script is running on? You can use Win32::API for that, in case there's no more specific (and maybe even better) module available. Don't get me wrong, I love Win32::API.

#!/usr/local/bin/perl -wl use Win32::API; my $GetComputerName = Win32::API->new("Kernel32", "GetComputerNameA", +"PP", "N") or die "Oops!"; my $computer = pack 'a256', ''; my $size = pack 'V', length($computer)-1; $GetComputerName->Call($computer, $size) or die "Oops, I don't know wh +o I am"; local $\ = "\n"; print unpack 'Z*', $computer;

But, wat are you actually trying to achieve? Are you trying to map specific volumes to drive letters, or something close? Because there are API calls available for those purposes, too, and you can use them from within Perl.


In reply to Re: IP Address by bart
in thread IP Address by SteveS832001

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.