p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning Regular Expressions
This is the forum to discuss the Wrox book Beginning Regular Expressions by Andrew Watt; ISBN: 9780764574894

Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Regular Expressions section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 2nd, 2009, 11:39 AM
Registered User
Points: 18, Level: 1
Points: 18, Level: 1 Points: 18, Level: 1 Points: 18, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Hi

Hi all,

I am new to perl and I do not know how to open file with @argv.


Thanks
allenbir
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old September 2nd, 2009, 12:03 PM
Friend of Wrox
Points: 1,882, Level: 17
Points: 1,882, Level: 17 Points: 1,882, Level: 17 Points: 1,882, Level: 17
Activity: 7%
Activity: 7% Activity: 7% Activity: 7%
 
Join Date: May 2004
Location: India
Posts: 563
Thanks: 0
Thanked 14 Times in 14 Posts
Default

Please check the following URL:
http://perldoc.perl.org/functions/open.html

Code:
  1. # process argument list of files along with any includes
  2. foreach $file (@ARGV) {
  3. process($file, 'fh00');
  4. }
  5. sub process {
  6. my($filename, $input) = @_;
  7. $input++; # this is a string increment
  8. unless (open($input, $filename)) {
  9. print STDERR "Can't open $filename: $!\n";
  10. return;
  11. }
__________________
Om Prakash Pant
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old September 2nd, 2009, 12:49 PM
Registered User
Points: 18, Level: 1
Points: 18, Level: 1 Points: 18, Level: 1 Points: 18, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks om prakash

suppose I have a file 1.txt how can I open it with argv could you plz tell me I am new to perl.

Thanks

allen
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old September 2nd, 2009, 01:41 PM
Friend of Wrox
Points: 1,882, Level: 17
Points: 1,882, Level: 17 Points: 1,882, Level: 17 Points: 1,882, Level: 17
Activity: 7%
Activity: 7% Activity: 7% Activity: 7%
 
Join Date: May 2004
Location: India
Posts: 563
Thanks: 0
Thanked 14 Times in 14 Posts
Default

Example:1
Code:
$str = <MYDATA>;
use strict;
open(MYDATA, "1.txt") or 
  die("Error: cannot open file 'data.txt'\n");
my $line;
my $lnum = 1;
while( $line = <MYDATA> ){
  chomp($line);
  print "$lnum: $line\n";
  $lnum++;
}
close MYDATA;
Example:2
Code:
@lines = <MYDATA>;
open(MYDATA, $ARGV[0]) or die("Error: cannot open file '$ARGV[0]'\n");
More Examples:
http://ist.marshall.edu/ist334/perl_fio.html
__________________
Om Prakash Pant
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #5 (permalink)  
Old September 4th, 2009, 09:03 AM
Registered User
Points: 18, Level: 1
Points: 18, Level: 1 Points: 18, Level: 1 Points: 18, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Thanks

Thank you very much om prakash.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #6 (permalink)  
Old September 4th, 2009, 11:06 AM
Registered User
Points: 18, Level: 1
Points: 18, Level: 1 Points: 18, Level: 1 Points: 18, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default HI

Hi,

I have a 2 files like

File 1 has entries like this
PF00912
PF00913
PF00914
PF00915
PF00916
..
..

File2

>128UP_DROME |==============================================| P32234.2 368 a.a.
MMR_HSR1 1 ______________ (9407) PF01926.15 GTPase of unknown function 65-176
TGS 1 _________ (2078) PF02824.13 TGS domain 292-366

>12KD_FRAAN |=====================================| Q05349.1 111 a.a.
Auxin_repressed 1 __________________________________ (61) PF05564.4 Dormancy/auxin associated protein 7-110

>12S1_ARATH |================================================| P15455.2 472 a.a.
Cupin_1 2 _______________ _______________ (1556) PF00190.14 Cupin 41-199 295-444

>12S2_ARATH |==============================================| P15456.2 455 a.a.
Cupin_1 2 ________________ _______________ (1556) PF00190.14 Cupin 35-192 282-431

>12S_PROFR |===============================================| Q8GBW6.3 611 a.a.
Carboxyl_trans 1 ______________________________________ (2491) PF01039.14 Carboxyl transferase domain 34-522

>13S1_FAGES |================================================| O23878.1 565 a.a.
Cupin_1 2 __________________ ____________ (1556) PF00190.14 Cupin 49-275 390-539

Problem is that I need to take one entry at a time from File1 , i.e PF00912 and match it with the File 2 in such a way that , if it found match then it should do the following ,

1. Take one entry from the file1 say like PF00912 and look it into file2.
2. Take only that enteries that starts from > to next > in file 2 that has PF00912 in it.
3. In file 2 look for the position after this |=====|, say like this P32234 (in file2) take this name and store it.
4. Look for PF* entries and numbers like 65-176 (can be any) in that same P32234 and then classify accordingly

a. if no. of PF* (1 only) and 65-176 (1 only any number) put P32234 into bin1 and

b. if no. PF* (more than 1) and 65-176 (1 only) for each PF* put P32234 into bin2 and

c. if no. PF* (1 only) and 65-176 (more than 1 times) put P32234
or no. if PF* (more than 1) and 65-176 (more than 1) put P32234 put them into bin3

d. if no. PF* (1 only) and 65-176 (more than 5) put them in bin 4

* note 65-176 can be any number.

5. At final we need to count the number of entries in each bin.

Thanks in advance

allen
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #7 (permalink)  
Old September 9th, 2009, 08:05 AM
Registered User
Points: 18, Level: 1
Points: 18, Level: 1 Points: 18, Level: 1 Points: 18, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help

Can any one help me with the above written problem.

Thanks in advance

allenbir
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump



All times are GMT -4. The time now is 12:38 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc