Last change
on this file since 37 was
37,
checked in by (none), 14 years ago
|
Added original make3d
|
-
Property svn:executable set to
*
|
File size:
746 bytes
|
Rev | Line | |
---|
[37] | 1 | #!/usr/bin/perl |
---|
| 2 | |
---|
| 3 | # permute a b c ... |
---|
| 4 | # reorders the words on each line |
---|
| 5 | # good for rearranging/selecting columns from ls, etc. |
---|
| 6 | # first word is word 0 |
---|
| 7 | # e.g. "echo a b c d e f" |
---|
| 8 | # a b c d e f |
---|
| 9 | # e.g. "echo a b c d e f | permute 4 2" |
---|
| 10 | # e c |
---|
| 11 | # |
---|
| 12 | |
---|
| 13 | # check usage |
---|
| 14 | if ($#ARGV == -1 || substr($ARGV[0],0,1) eq "-") { |
---|
| 15 | print STDERR "Usage: permute <col1> [col2] [col3]...\n"; |
---|
| 16 | print STDERR " e.g. \"echo a b c d e f\"\n"; |
---|
| 17 | print STDERR " a b c d e f\n"; |
---|
| 18 | print STDERR " e.g. \"echo a b c d e f | permute 4 2\"\n"; |
---|
| 19 | print STDERR " e c\n"; |
---|
| 20 | exit(-1); |
---|
| 21 | } |
---|
| 22 | |
---|
| 23 | |
---|
| 24 | |
---|
| 25 | # split on whitespace |
---|
| 26 | while (<STDIN>) { |
---|
| 27 | @words = split(' ', $_); |
---|
| 28 | for ($i=0; $i <= $#ARGV; $i++) { |
---|
| 29 | print $words[$ARGV[$i]]." "; |
---|
| 30 | } |
---|
| 31 | print "\n"; |
---|
| 32 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.