Ruby Is a Better Perl (Fight Me)
You've been lied to. Every Ruby tutorial starts with classes, objects, Rails scaffolding, and a mountain of ceremony that has nothing to do with getting actual work done. Here's the truth: Matz built Ruby as a better Perl. The command-line DNA is still there, hiding under years of web framework marketing. Time to dig it out.Part 1: The Minimal Ruby Manifesto
Inspired by Tim Maher's "Minimal Perl: For UNIX and Linux People," the idea is simple. You don't need to learn all of Ruby to get real work done. Accomplish 90% of tasks with maybe 10% of the language.Here's your entire toolkit for practical text processing:
- Hashes for counting and grouping
- Regex for matching and extraction
- ARGF for input (like Perl's diamond operator)
- puts for output
- Command-line switches (
-n,-p,-e,-a,-F)
That's it. No classes, no modules, no complexity.
Part 2: What Matz Actually Intended
Ruby was designed by Yukihiro "Matz" Matsumoto as "a better Perl" before Rails hijacked the narrative. The command-line DNA is still there:- All of Perl's favorite switches work
- Special variables behave the same way
- ARGF is actually more powerful than the diamond operator
- The regex engine is comparable
- Shell integration is excellent
- Quote-like operators (
%q,%Q,%r,%w,%x) mirror Perl'sq,qq,qr,qw,qx
Part 3: What to Focus On
- Command-line switches and special variables
- Regular expressions and text manipulation
- One-liners for text processing and log parsing
- Shell integration and pipeline construction
- File operations and in-place editing
- Running system commands
- Parsing structured data (logs, configs, CSV, JSON)
- Building filters that work with Unix tools
Part 4: What to Skip (Seriously, Skip It)
- Object-oriented programming (classes, modules, inheritance)
- Rails or any web framework
- Metaprogramming and eigenclasses
- Gems unless directly relevant to text processing
- Design patterns from the Rails world
- Testing frameworks
- Blocks as closures (use blocks for iteration only)
You don't need any of that to parse a log file at 3 AM.
Part 5: The Minimal Ruby Way
Run it like you'd run grep:#!/usr/bin/env ruby # Find failed SSH logins - the Minimal Ruby approach # Run like grep: ruby failed_ssh.rb /var/log/auth.log # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Track failed login attempts by IP # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ failed = Hash.new(0) # Hash with default value 0 for counting ARGF.each_line do |line| if line =~ %r~Failed password.*from\s+(\d+\.\d+\.\d+\.\d+)~ failed[$1] += 1 # $1 holds the captured IP end end # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Report sorted by count (descending) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ failed.sort_by { |ip, count| -count }.each do |ip, count| printf "%6d %s\n", count, ip end
ruby failed_ssh.rb /var/log/auth.log. No gems, no Gemfile, no bundle install. Just Ruby doing what Ruby was born to do.
Created By: Wildcard Wizard. Copyright 2026