Hi Perlmonks... I have some problem that may be trivial to most of you.. I have searched through the file input/output in the search.. and read them but doesn't seem to solve it. I have a very large file called me.db and each record in the file is separated by "\/\/\n" ( double/ and newline ). my file looks like this:
AB Naja atra (Chinese cobra). OC Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; OC Lepidosauria; Squamata; Scleroglossa; Serpentes; Colubroidea; OC Elapidae; Elapinae; Naja. OX NCBI_TaxID=8656; // DR Pfam; PF00087; toxin; 1. DR PRINTS; PR00282; CYTOTOXIN. DR ProDom; PD000206; Snake_toxin; 1. DR PROSITE; PS00272; SNAKE_TOXIN; 1. KW Venom; Cytotoxin; Cardiotoxin; Multigene family; 3D-structure; Si +gnal. FT SIGNAL 1 21 FT CHAIN 22 81 CYTOTOXIN 2. FT DISULFID 24 42 //
I give this file as an input when I compile it such as:
perl myprog.pl a.db
and I want to go to each record in the file and do something there.. But my code below.. they loop more than expected. For eq if I have 28 records separated my "\/\/\n" then they will loop until 70 times or more. This is my code:
$/ = "\/\/\n"; $counter=1; while (<>){ # Read the entry print "Entry $counter\n"; print "I don't know what to do \n"; #do something $counter++ }
Last time I also try this which is also doesn't work well:
my $infile =$ARGV[0]; open(IN, $infile) or die "Can't open input file: $!"; $/ = "\/\/\n"; $counter=1; while (<IN>){ # Read the entry print "Entry $counter\n"; print "Hallo to you....\n"; # do something $counter++ }
So what do I have to do? Thanks in advanced.

In reply to hm strange loop for me.. by agustina_s

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.