LaylaNahar
Programmer
Hi there,
I have some files in which I want to eliminate lines with no text. currently I'm just eliminating those lines which have only the "\n" character on them like so:
if (($lines[$i] eq "\n") && ($lines[$i+1]) && ($lines[$i+2]))
{
chomp ($lines[$i]);
}
I'd like to replace most of the lines that are only whitespace. I feel pretty confident that I have detcted them, I am just not sure what perl syntax to use to eliminate lines that consist of more whitespace than just "\n". Here's what I've got. Can you recommend something for the body of this if statement?
if (($lines[$i] =~/\s/) && ($lines[$i+1]=~/\s/) && ($lines[$i+2] =~ /\s/))
{
# something to eliminate all characters
}
thank you very much!
LN
I have some files in which I want to eliminate lines with no text. currently I'm just eliminating those lines which have only the "\n" character on them like so:
if (($lines[$i] eq "\n") && ($lines[$i+1]) && ($lines[$i+2]))
{
chomp ($lines[$i]);
}
I'd like to replace most of the lines that are only whitespace. I feel pretty confident that I have detcted them, I am just not sure what perl syntax to use to eliminate lines that consist of more whitespace than just "\n". Here's what I've got. Can you recommend something for the body of this if statement?
if (($lines[$i] =~/\s/) && ($lines[$i+1]=~/\s/) && ($lines[$i+2] =~ /\s/))
{
# something to eliminate all characters
}
thank you very much!
LN