#!/usr/bin/perl use strict; use warnings; for (){ if (m/^\s*Category (.*)$/){ print $1, $/; } }