in reply to Parsing Header Last Field

Your code (after the off by one error is fixed) does work, but you aren't getting much "mileage" out of ParseWords. I recoded without that below.

A few comments:
-don't push when you could print.
-there is no need to save all the output in an array.
-using a hash allowed me to get rid of variables like $Nr_1 and put code in same lingo as the file itself.
-this kind of "anonimization" is easily cracked - not so anon.
-you will need a better scheme if this data is sensitive.

#!/usr/bin/perl -w use strict; my $header_line = <DATA>; print $header_line; $header_line =~ s/\s*$//; # no trailing blanks or \n # a bit better than chomp() here # (chomp only gets rid of \n) # since words will be hash keys + my %index; # field name to index number my $i=0; foreach ( split /;/,$header_line ) { $index{$_}=$i++; } while(<DATA>) { next if /^\s*$/; # skip blank lines chomp; my @parts = split(/;/,$_); $parts[$index{Number}] =~ tr/0123456789/9876543210/; $parts[$index{Number_1}] =~ tr/0123456789/9876543210/; $parts[$index{Name}] =~ tr/A-Za-z/B-Wzb-w/; print join (";",@parts),"\n"; } =output Number;Name;Age;Gender;Number_1 876;Brhviw;54;m;876;AAA 765;Kslr;43;m;765;JJJ 654;Iipir;23;w;654;HHH =cut __DATA__ Number;Name;Age;Gender;Number_1 123;Andrew;54;m;123;AAA 234;John;43;m;234;JJJ 345;Helen;23;w;345;HHH