No doubt I should learn Perl more (and programming in general). I guess I managed to handle the print statement. Now, the code is:
#!/usr/bin/perl use strict; use warnings; my %info; # here we collect all information my @columns = qw(gi version cds); # The name and order of the columns +we want to print my $data = '/DATA/GenBankFile.gb'; # GenBank file is located at C:\DAT +A open INFILE, '<', $data or die "Cannot!\n"; while (<INFILE>) { if (m!GI:(\d+)!) { if ($info{cds}) { # we are in a CDS block $info{gi} = $1; }; } elsif (m!^\s+CDS\s+(.*)!) { # a new gene information has started flush_info(); # now remember the CDS $info{cds} = $1 } elsif (m!^VERSION.*\w:(\d+)! ) { $info{ version } = $1; #} else {warn "Ignoring unknown line [$_]\n";}; };} # Output any leftover information: #flush_info(); sub flush_info { # print out all information: print "$info{gi}"."\t"."$info{version}"."\t"."$info{cds}\n"; # and forget the collected information %info = (); }; >
And here is some part of the output:
Use of uninitialized value $info{"gi"} in string at C:\Perl\bin\wtf14. +pl line 32, <INFILE> line 154. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 154. Use of uninitialized value $info{"cds"} in concatenation (.) or string + at C:\Perl\bin\wtf14.pl line 32, <INFILE> line 154. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 180. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 206. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 232. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 258. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 284. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 314. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 345. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 374. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 404. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 434. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 481. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 498. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 534. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 600. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 617. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 634. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 667. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 710. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 721. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 746. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 773. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 836. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 848. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 860. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 892. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 938. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 952. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 996. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1009. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1046. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1070. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1098. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1131. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1174. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1188. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1216. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1256. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1269. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1329. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1344. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1360. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1403. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1415. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1445. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1490. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1505. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1533. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1591. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1606. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1621. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1710. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1767. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1781. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1795. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1827. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1865. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1899. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1934. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1982. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 1998. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 2048. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 2083. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 2119. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 2264. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 2282. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 2300. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 2337. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 2382. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 2419. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 2450. Use of uninitialized value $info{"version"} in string at C:\Perl\bin\w +tf14.pl line 32, <INFILE> line 2459. 30061484 join(68351..68408,76646..77058) 30061486 join(123270..123327,126056..126333) 83582801 join(138186..138234,139415..139665) 30061487 complement(join(168527..168759,170216..170264)) 197245446 join(207930..207987,209919..210412) 23943927 join(238420..238477,239718..239947) 55769555 complement(join(251848..251908,256609..256727, 21264338 278228..279439 197245445 306569..307516 41327717 join(330288..330476,333854..334279) 144953899 join(368655..368945,371931..372223,376842..377334) 5454168 join(389383..389423,398170..398263,398376..398574, 111185943 join(389402..389423,390525..390669,398170..398263, 47419901 complement(join(419230..419485,419752..419939, 4503095 complement(join(464605..464720,467020..467106, 29570791 complement(join(464605..464720,467020..467106, 48255908 complement(join(464605..464720,467020..467106, 22129777 complement(join(585235..585309,590357..590881)) 22129778 complement(join(629358..629561,633620..633829)) 197245441 join(629536..629555,633613..634228,642601..643113) 156564358 complement(join(644315..645105,656113..656245)) 108389007 complement(join(741670..741882,742345..742468, 46391104 825448..826335 108389127 825448..826335 21328453 825448..826335 83722283 complement(join(853603..853763,854927..855057, 90970328 complement(join(941000..941109,947817..947957, 145611425 complement(join(941000..941109,944578..944763, 145611430 join(1099417..1099545,1106141..1106293,1108069..11081 +51,

In reply to Re^12: Read, match string and print by sophix
in thread Read, match string and print by sophix

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.