Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

perl script

by sainath (Initiate)
on Jun 24, 2009 at 11:45 UTC ( #774362=perlquestion: print w/replies, xml ) Need Help??

sainath has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: perl script
by Transient (Hermit) on Jun 24, 2009 at 11:48 UTC
    What have you tried thus far?

    You'd probably want to take a look at using split to gather what you need.
Re: perl script
by citromatik (Curate) on Jun 24, 2009 at 12:04 UTC
    perl -lne '/gi\|(\d+)\|/ && push @sofar,$1}{$,=",";print @sofar' <yourfile>


      I used a similar idea but did as follows:

      my $file = '...the OPs File example..." #used as a string # to simplify my # test my @gi_ids = $file =~/gi\|(\d+)\|/g;

      That leaves the list @gi_ids containing all of the gi id's that were in the string (i.e., it finds 4 gi id's in the OPs example).

      Just another possible strategy. It looks to me like all of the respondents' ideas would work fine. Mine is just another variation.

      Hope that helps.

      ack Albuquerque, NM
Re: perl script
by leslie (Pilgrim) on Jun 24, 2009 at 12:58 UTC
    Hi firend,
    You can use this code..,
    use strict; use warnings; use Data::Dumper; my($File,$FILE_FH,$data,@total_data,$new,@gi); $File="./fasta.txt"; open $FILE_FH, '<', $File or die "Failed to Open File $File for $!"; $data=<$FILE_FH>; @total_data=split(/gi\|(\d+)\|/,$data); foreach $new(@total_data) { push @gi,$new if($new =~ /^\d+$/); } print Dumper @gi;

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://774362]
Approved by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2023-03-26 21:37 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (63 votes). Check out past polls.