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
#!/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; } }
|
---|