dingleberry
Programmer
I'm trying to figure out the syntax to test a line of a file I am parsing to determine if it is blank or not. Basically my file looks like this.
Joe
address 1
joe@testemail.com
fred
address 2
fred@testemail.com
etc
etc
etc
and what I'm doing is attempting to assign the values between the blank lines to an array. So when the script finds the login name (ie joe or fred) it starts populating the array until a blank line or line with nothing but spaces occurs. Here is my snippit.
open CUSTOMER, $customer or die "Can't open $log_file for reading: $!\n";
foreach my $line (<CUSTOMER>) {
chomp $line;
if ($line eq "$login"
{
while ($line != (/^\s*$/)) {
push (my @lines, $line);
}
print @lines;
}
}
I think the problem is in the while loop syntax, but I've never tested a line to see if it's blank this way so it's probably something silly like using ne instead of != or !=~ instead of !=.
I'm stumped. I think I've tried all these options. Any idea?
Thanks,
Dan
Joe
address 1
joe@testemail.com
fred
address 2
fred@testemail.com
etc
etc
etc
and what I'm doing is attempting to assign the values between the blank lines to an array. So when the script finds the login name (ie joe or fred) it starts populating the array until a blank line or line with nothing but spaces occurs. Here is my snippit.
open CUSTOMER, $customer or die "Can't open $log_file for reading: $!\n";
foreach my $line (<CUSTOMER>) {
chomp $line;
if ($line eq "$login"
while ($line != (/^\s*$/)) {
push (my @lines, $line);
}
print @lines;
}
}
I think the problem is in the while loop syntax, but I've never tested a line to see if it's blank this way so it's probably something silly like using ne instead of != or !=~ instead of !=.
I'm stumped. I think I've tried all these options. Any idea?
Thanks,
Dan