in reply to Reading in and writing files

Things you are doing wrong:

  1. Not indenting your code
  2. Not providing a working sample
  3. Not providing sample data
  4. Not providing sample output
  5. Not providing expected output
  6. Using a while loop where most likely you should use a for loop
  7. Apparently using 1 based indexing for arrays (Perl uses 0 normally)
  8. Using an empty else
  9. Explicitly listing all the elements in an array rather than using a slice
  10. (probably wrong) omitting a space in the string for join
  11. (possibly wrong) using a variable ($subcounter) without apparent initialisation
  12. Describing a problem you haven't provided code for

The last one is the kicker!


DWIM is Perl's answer to Gödel