Muthukumar <mailto:[EMAIL PROTECTED]> wrote:
: May be it will work: : : : open FD, "< pixconfig.txt"; : open FD1, "< ip.log"; : : @arr=<FD>; We need to know more about file size and memory to make this determination. Assuming you are correct about the file and memory size, your algorithm looks fine. You just need to learn more perl to make it work. I think better to keep files open for the shortest time possible, especially if this script might have several instances running at once. It is a good practice to check I/O operations for success. my $file = 'pixconfig.txt'; open my $fh, '<', $file or die qq(Cannot open "$file": $!); chomp( my @pix = <$fh ); close $fh or die qq(Cannot close "$file": $!); You can read more about chomp in the perlfunc file or by using perldoc from a command line (DOS box). perldoc -f chomp Since I introduced lexical variables above let me set you straight about all these symbol table polluting variables you are throwing around. *Don't use them*. Start even the smallest scripts you write with these lines. use strict; use warnings; For details: perldoc strict perldoc warnings So far we have this. #!/usr/bin/perl use strict; use warnings; my $file = 'pixconfig.txt'; open my $fh, '<', $file or die qq(Cannot open "$file": $!); chomp( my @pix = <$fh> ); close $fh or die qq(Cannot close "$file": $!); : while (<FD1>) : { : foreach $var (@arr) : { : $var=~chomp($var); : # print "Check" . $var . "<==>". $_; : if ( $_ =~ /.*$var.*/ ) : { : print $_; : } : } : } $file = 'ip.log'; open $fh, '<', $file or die qq(Cannot open "$file": $!); while ( my $ip = <$fh> ) { foreach my $pic ( @pix ) { next unless $ip =~ /\Q$pic\E/; print $ip; } } close $fh or die qq(Cannot close "$file": $!); __END__ While this is not the most optimal solution, it is easy to read and to maintain. If ip.log is very long, another, more advanced, solution is needed, but it would also require a more intimate knowledge of the data. HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>