sub remove_trailing_newlines( $ ) { my ( $stringref ) = @_; ${$stringref} =~ s/[\r\n]+\z//gs; }