in reply to Re: printing column info without headers
in thread printing column info without headers

thanks, what happens if the if in the 'next' line isn't true. Does the script then move down to the following line of code in the script??
  • Comment on Re^2: printing column info without headers

Replies are listed 'Best First'.
Re^3: printing column info without headers
by toolic (Bishop) on Jul 09, 2008 at 16:14 UTC
    The code I showed is extremely simple because your input file example is extremely simple. The code I presented will read in a file and will ignore all lines which begin with the string "Number1" because of the next statement. For all other lines which do not begin with "Number1", the numbers will be stored in an array. The script will generate warnings if there are blank lines (because of the print).

    Your actual file probably has a more complicated structure than your example file, but I can not predict its structure without more information from you.

Re^3: printing column info without headers
by blazar (Canon) on Jul 16, 2008 at 17:16 UTC
    thanks, what happens if the if in the 'next' line isn't true.

    (If that's a question, then it should be closed with a question mark, incidentally.)

    I personally believe that as with any other C<if>, if the condition isn't true, then the statement, i.e. next is not executed. Then, as with (nearly) any other statement, (that it has a statement modifier doesn't change this) control is passed to the following one. Pretty ordinary stuff, as you can see.

    (Apologies for replying so late.)

    --
    If you can't understand the incipit, then please check the IPB Campaign.
Re^3: printing column info without headers
by annie06 (Acolyte) on Jul 09, 2008 at 15:55 UTC
    reason I'm asking is because it seems to me we would then break out of the while loop. I don't want to do that, I'd like to still be able to continue on and look for other strings in the file..etc..
      next will not break out of the while loop; last would break out of the loop.

      I personally believe you shouldn't be (mis)guided by what could possibly seem to you, but rather resort to the actual docs, which tell you what that is. Incidentally, YMMV but I personally find "next" very intuitive as a term to suggest that it won't break out of the loop: just as much as "last" is about the fact that it will.

      (Apologies for replying so late.)

      --
      If you can't understand the incipit, then please check the IPB Campaign.