> This is what I have: > |xx-xxx-xxxxx-xxx x/xx|xx-xxxx-xxx-xx-xxxx-xx-xx| > This is what I want: > xx-xxx-xxxxx-xxx,x/xx,xx,xxxx,xxx,xx,xxxx,xx,xx, #### #!/usr/bin/perl use strict; my $string = '|xx-xxx-xxxxx-xxx x/xx|xx-xxxx-xxx-xx-xxxx-xx-xx|'; print "$string\n"; # remove pipe, protect everything before the space $string =~ s{^[|](\S+)}{}; my $result = $1; # translate pipes, spaces, and hyphens to commas $string =~ tr[| -][,]; $result .= $string; print "$result\n";