---
title: "Output Record Separator in Ruby"
url: https://daily.dev/posts/output-record-separator-in-ruby-vxlh3eckp
source_url: https://avdi.codes/output-record-separator-in-ruby
type: article
source: "RUBYLAND"
published: 2026-08-25T19:52:53.094Z
updated: 2026-08-25T21:44:17.732Z
tags: ["ruby", "rails"]
reading_time: 2
upvotes: 0
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Output Record Separator in Ruby

**[RUBYLAND](https://daily.dev/sources/rubyla)** · 2 min read · 0 upvotes · 0 comments

## Summary

Explains the meaning of Ruby's obscure $, (output field separator) and $\ (output record separator) global variables, sparked by a LinkedIn question about a trailing comma spotted in the Rails source. The default nil value means no separator, but setting these variables lets you generate CSV-like output from the command line without requiring the CSV library. Notes that this mnemonic global variable is deprecated in Ruby 4.0, with the English module alias $OUTPUT_RECORD_SEPARATOR recommended instead for non-one-liner code.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://avdi.codes/output-record-separator-in-ruby>

## Questions this post answers

### What does the $, global variable mean in Ruby?

It is the output field separator, borrowed from Perl and AWK conventions, where comma is a common separator mnemonic. Its default value is nil, meaning no separator is inserted between values printed with methods like print. Setting it to a comma lets print output comma-separated values without requiring the CSV library.

_Developers puzzling over cryptic Ruby globals can find explainers like this through daily.dev._

### Is Ruby's $, global variable deprecated?

Yes, the mnemonic global variable $, (along with its counterpart $\, the output record separator) is deprecated starting in Ruby 4.0. The recommended replacement in non-one-liner code is the English module alias $OUTPUT_RECORD_SEPARATOR, which is more readable than the cryptic punctuation-based name.

_Ruby developers tracking upcoming 4.0 deprecations can follow changes like this on daily.dev._

### Why does Rails set sep to $, instead of nil in its source code?

Rails sets sep to the current global output record separator rather than hardcoding nil, so that the behavior complies with whatever separator convention a programmer has already configured via $,. Since $,'s default value is nil anyway, this preserves expected output formatting instead of overriding a developer's custom separator setting.

_Understanding quirky Rails source decisions like this helps developers debugging similar code via daily.dev._

## Similar posts on daily.dev

- [Pretty SQLite Output Persistently](https://daily.dev/posts/pretty-sqlite-output-persistently-sivyz9kzd) · RUBYLAND · 1 upvotes · 0 comments
- [The output must be cleaned \(with skill\)](https://daily.dev/posts/the-output-must-be-cleaned-with-skill--usa51bh9w) · thoughbot · 1 upvotes · 0 comments
- [your community gem host](https://daily.dev/posts/your-community-gem-host-vi4wnzc2b) · Ruby Flow · 0 upvotes · 0 comments
- [Ruby Weekly Issue 769: October 2, 2025](https://daily.dev/posts/ruby-weekly-issue-769-october-2-2025-t6zurgtze) · Ruby Weekly · 0 upvotes · 0 comments

---

Tags: [#ruby](https://daily.dev/tags/ruby), [#rails](https://daily.dev/tags/rails)

[View this post on daily.dev](https://daily.dev/posts/output-record-separator-in-ruby-vxlh3eckp)
