Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Re: Re: resolving ip's to names in a text file

by softworkz (Monk)
on Jul 20, 2001 at 16:36 UTC ( [id://98389]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: resolving ip's to names in a text file
in thread resolving ip's to names in a text file

I'm not sure of your input file but this should get you started in the right direction, if not maybe someone can learn a tip of two. HAVE FUN!
#!/usr/bin/perl-w use strict; use win32; my $in_name=$ARGV[0]; my $out_name=$ARGV[1]; our (@x); # new type of global declaraton # carefull commas needed I.E. our (@x, @y); # use vars qw ( @x @y ); <- obsolete global declaration # pass a reminder if($#ARGV < 1) { die "usage: ip.pl <input file> <output file>\n" . "for example: program.pl infile.txt outfile.txt\n" } open(FILE, $in_name) || die "ip.pl can't open $in_name: $!"; open(IPFILE,">$out_name") || die "ip.pl can't open $out_name: $!"; my $dns2="toto"; #157.173.20.2 my $dns3="oz"; #157.173.20.3 my $dns4="wizard"; #157.173.20.4 my $ip2; my $ip3; my $ip4; while (<FILE>){ # sample line # Tz25,D,wizard,2,157.173.20.2,Local @x=split(/,/); next unless (($_ =~ /Local/)||($_ =~ /Network/)); if ($x[4] =~ /157.173.20.2/){ $ip2 = $dns2; print $x[0], $x[1], $x[2], $ip2; print IPFILE; } }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2024-04-23 17:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found