LINE: while ( my $line = ) { chomp $line; next LINE unless $line =~ m{\S}; next LINE if $line =~ m{\a\s*\#}xms; # process line }