I think you have an off-by-one error. Change:
for ( my $i = 0 ; $i <= @parts ; $i++ ) {
to:
for ( my $i = 0 ; $i < @parts ; $i++ ) {

You probably need to chomp @Proto, then add the newline back to your @Assembly.

After using perltidy, here are the changes:

use warnings; use strict; use Text::ParseWords; my @Proto = <DATA>; chomp @Proto; my $Header = shift @Proto; my @Assembly; my $Nr = &parsingHeader( $Header, "Number" ); my $Nr_1 = &parsingHeader( $Header, "Number_1" ); my $name = &parsingHeader( $Header, "Name" ); foreach (@Proto) { my @fields = quotewords( ';', 0, $_ ); $fields[$Nr] =~ tr/0123456789/9876543210/ if defined $Nr; $fields[$Nr_1] =~ tr/0123456789/9876543210/ if defined $Nr_1; $fields[$name] =~ tr/A-Za-z/B-Wzb-w/ if defined $name; push @Assembly, join( ";", @fields ), "\n"; } unshift @Assembly, $Header; print @Assembly; sub parsingHeader { my $x; my $Row = shift @_; my $Column = shift @_; my @parts = split( /;/, $Row ); for ( my $i = 0 ; $i < @parts ; $i++ ) { if ( $parts[$i] eq $Column ) { $x = $i; last; } } return $x; } __DATA__ Number;Name;Age;Gender;Number_1;Dummy 123;Andrew;54;m;123;AAA 234;John;43;m;234;JJJ 345;Helen;23;w;345;HHH

In reply to Re: Parsing Header Last Field by toolic
in thread Parsing Header Last Field by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.