#!/usr/local/bin/perl -w eval 'exec /usr/local/bin/perl -w -S $0 ${1+"$@"}' if 0; # not running under some shell # $Id: colrm,v 1.1.1.1 2001/06/06 08:54:18 sdague Exp $ use strict; $0 =~ s(.*/)(); my $usage = "usage: $0 [startcol endcol]\n"; my ($startcol, $endcol); # I could be more clever, but this will run faster if (@ARGV > 2) { die $usage; } elsif (@ARGV == 0) { print while(<>); } elsif (@ARGV == 1) { $startcol = (shift() - 1); while (<>) { print substr $_, 0, $startcol; print "\n"; } } elsif (@ARGV == 2) { $startcol = (shift() - 1); $endcol = (shift() - 1); while (<>) { chomp; substr($_, $startcol, $endcol) = ''; print "$_\n"; } } =head1 NAME colrm - remove columns from a file =head1 SYNOPSIS colrm [startcol [endcol]] =head1 DESCRIPTION B removes the named columns from each line of its standard input (one column = one character). Column numbering starts at 1, not 0. If a only I is provided, removes all columns from I rightwards. If both I and I are provided, removes all columns from I to I, inclusive. If neither is provided, acts just like B. If I is greater than I, or the arguments aren't numeric, it pretends it heard no arguments at all, just like the Linux version. =head1 OPTIONS AND ARGUMENTS =over 2 =item I The first column to remove. =item I The last column to remove. =back =head1 AUTHOR Jeffrey S. Haemer =head1 BUGS Lacks the special-case handling of backspace and tab added in some other versions. Acts, instead, like the simpler Linux and SunOS versions. =head1 SEE ALSO awk(1)