#!/usr/bin/perl # The Missing Textutils, Ondrej Bojar, obo@cuni.cz # http://www.cuni.cz/~obo/textutils # # 'revfields' reverses the order of fields on every line. # # To sort files by their extensions (suffixes), you might use "ls -1 | revfields --delim=. | sort | revfields --delim=." # # To cut the last column of a file, use "revfields | cut -f1". # # $Id: revfields,v 1.2 2005/10/10 07:33:50 bojar Exp $ use strict; use Getopt::Long; my $delim = "\t"; GetOptions("delim=s"=>\$delim); my $redelim = $delim; $redelim =~ s/([.^\$()\[\]*+])/\\\1/g; while (<>) { chomp; my @line = split /$redelim/o, $_; my @revline = reverse @line; print join($delim, @revline)."\n"; }