# encode all the '#' chars before we join s/#/%35/g for values % details; # now the only '#' chars represent our delimiter my $entry = join "#", values %details; # getting the data from the file we reverse the process # first split on the '#' char to get our values my @values = split "#", ; # now unencode any encoded '#' chars in @values s/%35/#/g for @values;