Re: find a first column value ...



BD schreef:

if I give any accession no like AW780891
than it should find the first column value like 203253.

If you only need to find one value per run:

#!/usr/bin/perl
use strict;
use warnings;

while ( <DATA> )
{
/ ^ (\d+) .* [ ]GB[|] ${ARGV[0]} [ ] /x
and print "$1\n" and exit(0)
}
exit(1)

__DATA__
203252 GB|AI461105 GB|AI900630 GB|AI900894 GB|AI901187
203253 GB|AI736220 GB|AW780891 GB|BE806781 GB|BG157087
203254 GB|AI440899 GB|AW185396 GB|AW185458 GB|AW152990
203255 GB|AI416923 GB|AI437726 GB|AI437966 GB|AI438062
203256 GB|AI441714 GB|AI930592 GB|AI855868 GB|AI856032


--
Affijn, Ruud

"Gewoon is een tijger."


.



Relevant Pages

  • Re: Perl script question
    ... > How can I grab the last data of the first column of the output of ... use strict; ... Also, if you would have used warnings and strictures, then perl would have ...
    (comp.lang.perl)
  • Re: regex count
    ... If the first column of your output is supposed to be a count (for that source ... use strict; ... use warnings; ... like the way the regex is broken up making it easier to understand. ...
    (perl.beginners)
  • Re: calculate the value in an array of array
    ... chen li schreef: ... How do I get the total values for each colume ... use warnings; ... use strict; ...
    (perl.beginners)
  • Re: Text parsing and substitution
    ... maheshpop1@xxxxxxxxx schreef: ... This assumes that the fields are allways in the same order: ... use strict; ... use warnings; ...
    (comp.lang.perl.misc)
  • Re: Simple averaging.
    ... number in the first column and an average for the values associated ... use warnings; ... use strict; ... printn NF "1 $avg1\n"; ...
    (perl.beginners)