make getpeername() return the original socket address which before it was intercepted
[hband-tools.git] / tabdata / td-rename
blobc4f5e3f0c82ba91f0f1702890aa15ce38e93a875
1 #!/usr/bin/env perl
3 =pod
5 =head1 NAME
7 td-rename - Rename tabular data columns
9 =head1 USAGE
11 td-rename I<OLDNAME> I<NEWNAME> [I<OLDNAME> I<NEWNAME> [I<OLDNAME> I<NEWNAME> [...]]]
13 =head1 EXAMPLE
15 conntrack -L | sd '^(\S+)\s+(\S+)\s+(\S+)' 'protoname=$1 protonum=$2 timeout=$3' | kvpairs2td | td-rename _REST FLAGS
17 =head1 SEE ALSO
19 Not to confuse with rename.td(1) which renames files, not columns.
21 =cut
23 no if ($] >= 5.018), 'warnings' => 'experimental::smartmatch';
24 do '/usr/lib/tool/perl5/tabdata/common.pl' or die "$@";
25 use Data::Dumper;
27 process_header(scalar <STDIN>);
29 %renames = @ARGV;
31 RENAME:
32 for my $oldname (keys %renames)
34 COLUMN:
35 for my $colidx (0..$#Header)
37 if($Header[$colidx] eq $oldname)
39 my $newname = $renames{$oldname};
40 $Header[$colidx] = $newname;
41 delete $Header{$oldname};
42 $Header{$newname} = $colidx;
43 next RENAME;
48 print join($FS, @Header).$RS;
50 print while <STDIN>;