use strict; my @origarray=('1|:|Test','2|:|Hash','3|:|Stuff','4|:|India'); print join("\n",sort {(substr $a,4) cmp (substr $b,4)} @origarray);