#!/usr/bin/perl # The Missing Textutils, Ondrej Bojar, obo@cuni.cz # http://www.cuni.cz/~obo/textutils # # Given a column number, 'split_at_colchange' adds an empty line whenever the # value in the column changes. Useful as a preprocessing before 'blockwise'. # # $Id: split_at_colchange,v 1.2 2006/06/16 08:36:05 bojar Exp $ # use strict; my $col = shift; die "split_at_colchange < input > blocks" if !$col; $col--; my $lastval; while (<>) { my @line = split /\t/, $_; # print STDERR "E: $lastval vs. $line[$col]; $col\n"; if (defined $lastval && $lastval ne $line[$col]) { print "\n"; } $lastval = $line[$col]; print; }