#!/usr/bin/perl # http://perlmonks.org/?node_id=1169831 use strict; use warnings; $_ = <<END; a 23 11 b 24 15 c 16 19 d 8 2 e 40 41 END s/ +/\t/g; # replace tabs if pasted out my @array; @array[sort {$b <=> $a} /\t(\d+)\t/g] = 1..tr/\n//; s/\t\K(\d+)(?=\t)/$array[$1]/ge; @array[sort {$b <=> $a} /\b(\d+)$/gm] = 1..tr/\n//; s/\b(\d+)$/$array[$1]/gem; print;
In reply to Re: manipulating a data table
by Anonymous Monk
in thread manipulating a data table
by v15
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |