use warnings; use strict; my $str = 'RcdA|CON|139|||Kan|13|J|J|607|abc@gmail.com'; $str =~ s/(.*)\|.*/$1/; print "$str\n";