# $Id: get_line.pl,v 1.1 1997/04/03 07:39:42 friedman Exp $

# This routine returns the next non-blank line, with leading and trailing
# whitespace (including trailing newline) trimmed.
sub get_line
{
  local ($handle, $errmsg, $return_on_error_p) = @_;

  while (1)
    {
      $_ = <$handle>;

      if (! defined ($_))
        {
          &backtrace ($errmsg, $return_on_error_p) if defined ($errmsg);
          return undef;
        }

      chop;
      s/^[ \t]+//o;
      s/[ \t]+$//o;
      return $_ if ($_ ne '');
    }
  return undef;
}
