perl with two files and print


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting perl with two files and print
# 1  
Old 07-26-2009
Java perl with two files and print

Suppose u have two files

one file
>hi|23433|sp|he is RAJ<space>>hi|23333|df|He is HUMAN<space>>hi|222|gi|howru|just
WOWHEISWONDERFUL
>hi|25559|gs|heisANUJ<space>>hi|2232|sp|he is fool
SKSIKSIKSLKSSLLS

Another file
HUMAN


so output wil be ...if the list contain HUMAN only take it as shown:
HUMAN hi|23433|sp|he is RAJ

Code:
#! /usr/bin/perl -w

open(FILE,"$ARGV[0]") or die;
my @temp=<FILE>;
close FILE;

my $f=join("",@temp);
$f=~s/^>gi/ronaldo/g;
my @reco=split("ronaldo",$f);
my $dis=shift(@reco);
pen(FILE,"$ARGV[1]") or die;
my @temp1=<FILE>;
close FILE;

if($reco =~ /$temp1/)
{
print "YES";
}
else {
print "NO??????\n\n";
exit;
}

it is not gud perlscript only it will print either YES or NO
?
Whta can be possible solution

Last edited by cdfd123; 07-26-2009 at 02:29 PM.. Reason: coloring the space
# 2  
Old 07-26-2009
Quote:
Originally Posted by cdfd123
...

one file
>hi|23433|sp|he is RAJ<space>>hi|23333|df|He is HUMAN<space>>hi|222|gi|howru|just
WOWHEISWONDERFUL
>hi|25559|gs|heisANUJ<space>>hi|2232|sp|he is fool
SKSIKSIKSLKSSLLS

Another file
HUMAN

so output wil be ...if the list contain HUMAN only take it as shown:
HUMAN hi|23433|sp|he is RAJ

...

Code:
$ 
$ cat f1
>hi|23433|sp|he is RAJ >hi|23333|df|He is HUMAN >hi|222|gi|howru|just
WOWHEISWONDERFUL
>hi|25559|gs|heisANUJ >hi|2232|sp|he is fool
SKSIKSIKSLKSSLLS
$ 
$ cat f2
HUMAN
$ 
$ perl -ne 'BEGIN{open(F2,"f2");chomp($x=<F2>);close(F2)}{print $x," ",substr($_,1,index($_,">hi",1)-1),"\n" if /$x/}' f1
HUMAN hi|23433|sp|he is RAJ 
$

tyler_durden
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Print the name of files in the directory using Perl

Hi All, I am stuck with a problem and i want your help, what i want to do is I have a directory name dircome and there are 6 files present in this directory, the name of the files are d1,d2,d3,d4,d5,d6. The Perl script print the files name, means the output should be d1 d2 d3 d4 d5 d6 (9 Replies)
Discussion started by: parthmittal2007
9 Replies

2. Shell Programming and Scripting

color print using perl

Hi i want to print the text in different color using perl script. i am able to print on console(terminal). but if i try to print the same into a file, i am not able to do color.pl #!/bin/usr/perl use Term::ANSIColor; print "This text is normal.\n"; use Term::ANSIColor qw(:constants);... (3 Replies)
Discussion started by: roopa
3 Replies

3. Shell Programming and Scripting

Perl print between 2 patterns

I have been unable to find this anywhere; I have a multiline variable, and I want to print the text between two patterns in that variable. So the variable is My real name is not DeadmanAnd I need the output to be this, by printing between "real" and "not" name is or including the two... (10 Replies)
Discussion started by: killer54291
10 Replies

4. Shell Programming and Scripting

Perl :How to print the o/p of a Perl script on console and redirecting same in log file @ same time.

How can i print the output of a perl script on a unix console and redirect the same in a log file under same directory simultaneously ? Like in Shell script, we use tee, is there anything in Perl or any other option ? (2 Replies)
Discussion started by: butterfly20
2 Replies

5. Shell Programming and Scripting

awk -F'|' '{ print $5 }' in perl

Hi guys i need you help its urgent.. im trying to translate this file processing command in Perl. awk -F'|' '{ print $5 }' any ideas ;) Regards (6 Replies)
Discussion started by: raid5
6 Replies

6. Shell Programming and Scripting

using perl to print columnwise

Suppose we have two files one file FAAA_HUMAN.input1 2 5 7 11 and another file FAAA_HUMAN.output M*0.0540*0.0039*0.2212*0.0082*0.0020*0.0137*0.0028*0.0029*0.2198*0.0104*0.0889*0.0282*0.0049*0.0804*0.1743*0.0215*0.0531*0.0071*0.0007*0.0021*0.7270*2.5000*... (4 Replies)
Discussion started by: cdfd123
4 Replies

7. Shell Programming and Scripting

using perl to print 1 or 0

Suppose u have a file FILE A ABCA10 DIFF VALUES P203S POLY ABCA1 DIFF VALUES A1046D ABCA4 DIFF VALUES D846H POLY ABCA4 DIFF VALUES I1846T POLY ABCA4 DIFF VALUES Wa ABCA4 DIFF VALUES WA ABCA4 DIFF VALUES Wb and u want to print that if FILE A have POLY so print 0 otherwise 1 means... (1 Reply)
Discussion started by: cdfd123
1 Replies

8. Shell Programming and Scripting

Perl: Search and print help

Hi all, I need a bit of help with a perl script, I have a file containing lines that look like: M1 (Agnd Agnd ibias_gnP Agnd) nch l=250.0n w=10u m=1 ad=2.5e-12 \ as=2.5e-12 pd=20.5u ps=20.5u nrd=0.025 nrs=0.025 sa=2.5e-07 \ sb=2.5e-07 M21 (Agnd VSSabc Agnd Agnd) nch... (3 Replies)
Discussion started by: Crypto
3 Replies

9. UNIX for Dummies Questions & Answers

perl print command

Hi, I am running this command in perl print "this is a test message @1.00 pm\n" but the output i am getting as this is a test message .00 pm pls help, how to get the proper output (2 Replies)
Discussion started by: vasikaran
2 Replies

10. Shell Programming and Scripting

PERL: print if files present

FOR: Windows NT 4 I want perl to read a directory. there is suposed to be two files in the folder ( file1.ini and file2.ini ) and i want perl to print "Files present" or "Files NOT present" to a text document ( report.txt ) how do i do it.? (2 Replies)
Discussion started by: perleo
2 Replies
Login or Register to Ask a Question