Hii everybody..I have posted a similar question before..but it is slightly changed and I am not finding how to solve it..Please help..
I have a text file with some compound names..now I want a perl program which will scan the whole text file and then if for any entry, C>10 and p<5 found, it'd copy that entry to a new text file.
I have uploaded a sample input text file also.
Thanks in advance...

Recommended Answers

All 3 Replies

use strict;
use warnings;

open(FILE,"<example1.txt");
open(OUT,">example2.txt");

my $x=0;
while(<FILE>){
	chomp;
	$x++;
	if($x==1){
		print OUT "$_\n";
		next;
	}
	my ($Compound,$H,$C,$N,$O,$P,$S,$Cl,$Co,$Se,$Class)=split(/\t/);
	if($C>10 && $P<5){
		print OUT "$_\n";
	}
}

close FILE;
close OUT;

thanks..but one small question? Do you think that the text file I uploaded was properly tab-delimited? If not, how to do so? cheers...

Mark post as closed ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.