#!/usr/local/bin/perl -w eval 'exec /usr/local/bin/perl -w -S $0 ${1+"$@"}' if 0; # not running under some shell # # $Id: paste,v 1.1.1.1 2001/06/06 08:54:53 sdague Exp $ # # $Log: paste,v $ # Revision 1.1.1.1 2001/06/06 08:54:53 sdague # initial import # # Revision 1.1 2001/05/14 00:49:39 sdague # added more files # # Revision 1.0 1999/02/26 15:39:05 randy # Initial revision # use strict; no strict 'refs'; my ($VERSION) = '$Revision: 1.1.1.1 $' =~ /([.\d]+)/; my (@fh, $i); my @sep = ( "\t" ); my $dash_ess = 0; exit if not @ARGV; while ($ARGV[0] =~ /^-.+$/) { $_ = shift @ARGV; /^-\?$/ and do { print <) { chomp; $tline .= $_ . $sep[$current_sep++]; $current_sep = 0 if $current_sep == scalar @sep; } print "$tline\n"; close $fh; } exit; } my $files_still_open = 1; while (1) { my $current_sep = 0; $files_still_open = 0; foreach $i (0..$#fh) { $files_still_open = 1 if not eof $fh[$i]; } last if not $files_still_open; my $tline; foreach $i (0..$#fh) { if (not eof $fh[$i]) { my $fh; $fh = $fh[$i]; my $line = <$fh>; chomp($line); $tline .= $line; } $tline .= "$sep[$current_sep++]" if $i != $#fh; $current_sep = 0 if $current_sep == scalar @sep; } print "$tline\n"; } __END__ =pod =head1 NAME paste - merge corresponding or subsequent lines of files =head1 SYNOPSIS paste [-s] [-d list] file... =head1 DESCRIPTION Paste combines the corresponding lines of multiple files. Each line of each file is printed seperated by tab (or by the characters listed in the -d option). =head2 OPTIONS I accepts the following options: =over 4 =item -d list Define the column delimiters. Each character in this list will be used one at a time, as a delimiter for the columns. If there are fewer characters than columns, the characters will be repeated. Standard Perl special characters ("\n", "\t", etc.) are recognized. =item -s Displays the output one file per row, rather than interleaving the lines of the files. =back =head1 ENVIRONMENT The working of I is not influenced by any environment variables. =head1 BUGS I has no known bugs, unless you count the use of eval EXPR. Getting it to work under 'strict refs' would be nice, too. =head1 REVISION HISTORY $Log: paste,v $ Revision 1.1.1.1 2001/06/06 08:54:53 sdague initial import Revision 1.1 2001/05/14 00:49:39 sdague added more files Revision 1.0 1999/02/26 15:55:05 randy Initial revision =head1 AUTHOR The Perl implementation of I was written by Randy Yarger, I. =head1 COPYRIGHT and LICENSE This program is copyright by Randy Yarger 1999. This program is free and open software. You may use, modify, distribute and sell this program (and any modified variants) in any way you wish, provided you do not restrict others to do the same. =cut Randy Jay Yarger | Nextel Communications randy.yarger@nextel.com | http://hs1.hst.msu.edu/~randy/