Guys,
please look at the following code:
Code:
#!usr/bin/perl -w
use strict;
open RMLOOK, "ip_names.lookup.removed";
open LOOK, "ip_names.lookup";
#open OUT, ">out.txt";
#open RMOUT, ">myout.txt";
my (@r,@l,@a,@b);
while(defined(my $bar=<LOOK>))
{
@a=split("\t",$bar);
while(defined(my $inf=<RMLOOK>))
{
# print $a[5];
@b=split("\t",$inf);
#print $b[0],"=>",$a[0],"\n";
if( $a[0] eq $b[0] )
{
# print "$bar$inf";
}
}
print $a[5];
}
this is printing different values. Where as:
Code:
#!usr/bin/perl -w
use strict;
open RMLOOK, "ip_names.lookup.removed";
open LOOK, "ip_names.lookup";
#open OUT, ">out.txt";
#open RMOUT, ">myout.txt";
my (@r,@l,@a,@b);
while(defined(my $bar=<LOOK>))
{
@a=split("\t",$bar);
while(defined(my $inf=<RMLOOK>))
{
print $a[5];
@b=split("\t",$inf);
#print $b[0],"=>",$a[0],"\n";
if( $a[0] eq $b[0] )
{
# print "$bar$inf";
}
}
# print $a[5];
}
The input files being:
cat ip_names.lookup
Code:
IPAddress Hostname Owner CustomerUsing NetworkType Location EmailAddress AssetType Service
.................
192.168.0.9 aaaa bbb world mant aaa world mant industry nY a@gmail.com DEsk N/A
192.168.0.9 aaaa bbb world mant aaa world mant industry nY a@gmail.com DEsk N/A
.................
cat ip_names.lookup.removed
Code:
IPAddress Hostname Owner CustomerUsing NetworkType Location EmailAddress AssetType Service Type no# Date
.................
192.168.0.9 aaaa bbb world mant aaa world mant industry nY a@gmail.com DEsk N/A Removed 345 06132007
192.168.0.9 aaaa bbb world mant aaa world mant industry nY a@gmail.com DEsk N/A Removed 345 06132007
.................
this printing the same value throughout the loop.
why???