#!/usr/bin/perl # The Missing Textutils, Ondrej Bojar, obo@cuni.cz # http://www.cuni.cz/~obo/textutils # # 'unsee' reverses the output see, i.e. produces each line that number times as # written in the first column. # # $Id: unsee,v 1.3 2006/03/04 09:04:01 bojar Exp $ # use strict; use Getopt::Long; my $fixtab = 0; GetOptions( "fixtab" => \$fixtab, # read the first number, delimited by a space instead of tab possibly ); while (<>) { s/^\s*([0-9]+)\s+/\1\t/ if $fixtab; my @line = split /\t/; my $num = shift @line; my $tail = join("\t", @line); foreach (1..$num) { print $tail; } }