Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: Text processing question - strange output

by frankus (Priest)
on Nov 20, 2001 at 22:56 UTC ( #126582=note: print w/replies, xml ) Need Help??

in reply to Text processing question - strange output

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:
  1. nbtstat each IP address in the file (hopefully XXX.XXX.XXX.XXX, 15 chars ;)
  2. Make a list of unique IP addresses (found at the beginning of each line returned)
  3. 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.


Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2023-12-09 06:07 GMT
Find Nodes?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?

    Results (37 votes). Check out past polls.