Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Hey guys

For all intensive purposes the script should work however I have one tiny problem. I cannot seem to skip from one iteration to the next. It just carries on.

use strict; open my $in, '<', 'CLF17936.out'; open my $out, '>', "logfile.txt"; my $check = 0; my @lines; LINE: while(<$in>) { @lines = split('', $_); $check += 1 if $lines[0] eq 'h'; if($check%2 == 1) { SWITCH: { if($lines[0] eq 'j') { my $first = substr $_, 37, 20; my $second = substr $_, 67, 3; print $out "\n Name: $first\t ABICODE: $second\n"; } if($lines[0] eq 'k') { my $qstatus = substr $_, 113, 1; if($qstatus ne "1") { print $out "FAIL\n"; next LINE; } } if(($lines[0] eq 'E') || ($lines[0] eq 'G')) { print $out "$_"; } } } } close($in);
It just needs to miss the last if statement if the above prints to $out as a FAIL. However in the out put file this is what I am getting
Name: B-D Z2 -10 ABICODE: 216 FAIL E99HEADER|004|001| E99INSSCH|216| E99POLCOM|3||CAP01|66|3301R7435459||||| E99INSFAC2|MSRZ01a||||||"00I10587"| E99INSFAC2|MSRZ01b||||||"335000 B"| G3301R7435459
Can anyone advise if its just something I've missed? Thanks Jim

In reply to Moving to next iteration of a while loop by Jalcock501

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (5)
    As of 2014-08-01 00:41 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (256 votes), past polls