-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnormalize
More file actions
executable file
·43 lines (27 loc) · 789 Bytes
/
normalize
File metadata and controls
executable file
·43 lines (27 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/perl
use strict;
use Getopt::Std;
use POSIX qw(ceil floor);
my $usage = "Usage: cat file | normalize -c [column] -p [plus] -x [divide] -a > output \n".
" -a uses the first value found in the first row at column c as the amount to subtract by, i.e. auto normalize";
my %para = ();
getopts('c:p:x:a', \%para);
while (my $line = <STDIN>) {
next if ($line =~ /^\#/);
my (@item) = split (/\s/,$line);
my $i = $item[$para{'c'}];
my $ip = $i;
next if (!defined($i));
if (!defined($para{'p'}) && defined($para{'a'})) {
$para{'p'} = -1 * $i;
}
if (defined($para{'p'})) {
$i += $para{'p'};
}
if (defined($para{'x'})) {
$i /= $para{'x'};
}
#print "was $ip now $i\n";
$item[$para{'c'}] = $i;
print "@item\n";
}