![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| StackedHash Perl program help | pcjandyala | Shell Programming and Scripting | 2 | 06-11-2008 11:52 AM |
| Run shell program in perl | s123.radha | Shell Programming and Scripting | 5 | 04-21-2008 09:39 AM |
| perl program question | hankooknara | Shell Programming and Scripting | 4 | 07-05-2007 11:01 AM |
| Invoke perl program from Ksh | mahalakshmi | Shell Programming and Scripting | 10 | 12-19-2006 08:46 AM |
| How to know the program 'perl' is installed ? | zp523444 | UNIX for Dummies Questions & Answers | 3 | 12-13-2005 07:06 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
an error in perl program
Hi
I am having a file with 243 lines.. The file format s given below eg P25787 hsa03050 1 P20618 hsa03050 1 P25786 hsa03050 1 P49721 hsa03050 1 P54132 hsa03440 1 Q13472 hsa03470 1 Q05513 hsa04530 hsa04910 hsa04930 3 Q04759 hsa04530 hsa04910 hsa04930 3 O43463 hsa00310 1 Q92769 hsa04330 hsa04110 hsa05200 hsa05220 hsa05016 5 Here i have to seperate this file in to two.. ie if the 8 letter alphanumerical word s same in both the ids den it should be printed in one file eg. P25787 hsa03050 1 P20618 hsa03050 1 P25786 hsa03050 1 P49721 hsa03050 1 Q05513 hsa04530 hsa04910 hsa04930 3 Q04759 hsa04530 hsa04910 hsa04930 3 The highlighted words shud be same And the other one if the 8 letter alphanumerical word s different den it shud be printed in a file eg P54132 hsa03440 1 Q13472 hsa03470 1 O43463 hsa00310 1 Q92769 hsa04330 hsa04110 hsa05200 hsa05220 hsa05016 5 I wrote a perl code for this but its no working properly the below given s the code Code:
open(f1IN,"infile1.txt");
@id = <f1IN>;
close(f1IN);
open(f2IN,"infile2.txt");
@content = <f2IN>;
close(f2IN);
open(f3OUT,">same.txt");
open(f4OUT,">occurence1.txt");
open(f5OUT,">notsame.txt");
foreach my $id (@id)
{
chomp($id);
my $count = 0;
foreach my $line (@content)
{
chomp($line);
$line =~ s/(\t|\s{2,})/ /g;
while ( $line =~ /hsa$id/gi )
{
$count ++;
}
@line = split(/ /,$line);
@count = grep /$id/,@line;
if ( scalar(@count) == 2 )
{
print f3OUT "$line\n";
}
else
{
print f5OUT "$line\n";
}
}
print f4OUT "$id --> $count\n"
}
close(f3OUT);
close(f4OUT);
close(f5OUT);
pls reply me asap Last edited by pludi; 2 Weeks Ago at 09:03 AM.. Reason: code tags, please... |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|