while( ) { s/#.*$//; # Lose comments s/^\s*//; # Lose leading w/s s/\s*$//; # Lose trailing w/s next unless $_; ... do stuff }