#!/usr/bin/perl # The Missing Textutils, Ondrej Bojar, obo@cuni.cz # http://www.cuni.cz/~obo/textutils # # 'numerize_blocks' adds a tab-delimited prefix to each block (blocks are # delimited by a blank line) such that each block gets a distinct number. # # Useful in combination with 'blockwise --auto-prefix' or 'grp' # # $Id: numerize_blocks,v 1.3 2005/12/10 14:46:53 bojar Exp $ # use strict; use Getopt::Long; my $squeeze = 0; GetOptions( "squeeze" => \$squeeze ); my $n = 1; while (<>) { if (/^$/) { $n++; print if !$squeeze; next; } print "$n\t$_"; }