Use " |x " for subfield ind, replacing x1f with " |x", where x is in [a-z] $var =~ s/\x1f[a-z]/ \|$& /g; Remove leading spaces $var =~ s/^ +//; Remove trailing space characters $var =~ s/\s+$//; Collapse "nonWord-char+space" to "space" $var =~ s/\W / /g; Collapse white space occurrences down to 1 space each $var =~ s/\s\s*/ /g; Convert input string to hexadecimal $var =~ s/(.)/sprintf ("%%%X", ord($1))/eg; Restore formfeed character as passthrough $var =~ s/^%C/sprintf("%c", 12)/e; Convert hex character value to equivalent unsigned char value $var =~ s/$hex_char_var/pack("C", hex($hex_char_var))/eg; Convert to upper case $var =~ tr/a-z/A-Z/; Remove LF at End Of Line $var =~ s/\n$//; Determine how many elements are populated in the array. In this case each element is 22 chars long. Loops until encounters empty element. (dependable?) $ctr = 0; while (not ($array[$idx] =~ /( ){22}/)) { $ctr++; $idx++ } Fields in $var are separated by " | ". Remove blank fields. $var =~ s/ \| \| / \| /g; Fields in $var are separated by " | ". Remove trailing blank fields. $var =~ s/ \| $//; Condition true if $var contains only digits if ($var =~ /^[0-9]+$/) {then true} True if date in $var is of format nn/nn/nnnn; no extra chars if ($var =~ /^\d{2}\/\d{2}\/\d{4}$/) {then true} Strip high ASCII chars from $var $var =~ tr/\x80-\xff//d; Count occurrences of string represented by "word" (destructive) $count = ($var =~ s/word//g); Replace all <...> constructs with "|" $var =~ s/\<([a-zA-Z0-9\/\=\"\#]+)\>/\|/g; File-wide substitution from the command line perl -pi -e's/\#\#\#/ /g' yourfile # sample substitution pattern