Mercurial > repos > devteam > add_value
diff fixedValueColumn.pl @ 0:181dd378275c
Uploaded add_value tarball.
author | devteam |
---|---|
date | Tue, 04 Dec 2012 10:37:05 -0500 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fixedValueColumn.pl Tue Dec 04 10:37:05 2012 -0500 @@ -0,0 +1,34 @@ +#! /usr/bin/perl -w + +use strict; +use warnings; + +# fixedValueColumn.pl $input $out_file1 "expression" "iterate [yes|no]" + +my ($input, $out_file1, $expression, $iterate) = @ARGV; +my $i = 0; +my $numeric = 0; + +die "Check arguments\n" unless @ARGV == 4; + +open (DATA, "<$input") or die "Cannot open $input:$!\n"; +open (OUT, ">$out_file1") or die "Cannot create $out_file1:$!\n"; + +if ($expression =~ m/^\d+$/) { + $numeric = 1; + $i = $expression; +} + +while (<DATA>) { + chop; + if ($iterate eq "no") { + print OUT "$_\t$expression\n"; + } else { + print OUT "$_\t$i\n" if $numeric == 1; + print OUT "$_\t$expression-$i\n" if $numeric == 0; + ++$i; + } +} + +close DATA; +close OUT;