in reply to Way to remove the new line characters at the end of the content in a file

Hi shroh. In addition to the above suggestions, see the response to your other question referencing Path::Tiny::lines and its chomp => 1 attribute. This will remove the newline character from the lines as they are pushed onto the array of lines. Then you can just do next if $line =~ /^$/;

The way forward always starts with a minimal test.