in reply to How do I split a file into an array using blank lines as delimiter

your code would work but the pattern you have '$string' splitting on is no good. Right now you have it matching any line with 0 or more whitespaces at the beginning. That's every line. Try this:
open (LOG,"Messages.log"); while (<LOG>){ $string .= $_; } @array = split(/\n{2,}/, $string); # note the new pattern
  • Comment on Re: How do I split a file into an array using blank lines as delimiter
  • Download Code