On Tue, 2007-05-15 at 12:25 +0800, Jeff Pang wrote:
> sivasakthi 写道:
> > Hi,
> > 
> > I have used the file in perl, file contains like that,
> > 
> > 1176369096.111    468 172.16.2.80 TCP_MISS/200 9629 
> > 1176378643.614    458 172.16.2.80 TCP_MISS/200 9626 
> > 1176378681.984    662 172.16.2.75 TCP_MISS/200 9626 
> > 1176436396.304   1142 172.16.2.80 TCP_MISS/200 13281 
> > 1176436397.228    916 172.16.2.99 TCP_REFRESH_HIT/200 7521 
> > 1176436469.060   1470 172.16.2.80 TCP_MISS/200 5822 
> > 
> > I have need to split the each column in to separate hash value,before
> > that i need to delete the particular user details from the file.For
> > example if a line contains the user I/P  of 172.16.2.80 then i should
> > delete that whole line and then split in to separate column. For that
> > what should i do??
> > 
> 
> while(<FILE>) {
>     my ($time,$lport,$ip,$stats,$rport) = split;
>     next if $ip eq '172.16.2.80';
>     # using those values above to create hash,based on what form of hash
> you needed.
> }
> 

in that i have checked the group of ip address, so i have used that ip
from hash as following,

open FF, "/tmp/userip.txt" or die $!;
$arrskip{$_}= 1 while (<FF>);

open FILE,"/tmp/file" or die $!;
while(<FILE>) {
    my ($time,$lport,$ip,$stats,$rport) = split;
        next if (exists ($arrskip{$ip}));
#some tasks..
}
close FILE;

userip.txt contains some collections of ip address which are need to be
deleted lines
/tmp/file contains the above format of no of columns

I have checked the above code, the collection of ip address lines are
not deleted correctly.

could u help me to find the soln??

Thanks,
Siva


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to