Tried using strict? It's a good habit to aquire.
I think what you're trying to do can be done with this:
use strict;
open(NB, "nbt.csv") or die "Error reading nbt.csv: $!\n";
while(<NB>){
chomp;
@nbtstat = `nbtstat -a $_`;
%_=map{$_,1}map{/^\d+.\d+\.\d+\.\d+/;$&}($_,@nbtstat);
print join(',',$_,keys(%_)),"\n";
}
As I understand it, you want:
- nbtstat each IP address in the file (hopefully XXX.XXX.XXX.XXX, 15 chars ;)
-
Make a list of unique IP addresses (found at the beginning of each line returned)
- Print the list to STDOUT comma seperated
Or have I got the wrong end of the stick?
Note: this'll print the original IP address twice.
--
Brother Frankus.
¤
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|