I have a list of names, separated by the '/' character in a variable, $list, and a name in the variable $name. If the name appears in the list, I want to remove it and clean up $list. It takes me 4 calls to s///, and it looks clunky. I have a feeling that someone out there on this list will know a cleaner way to do it.
/\/\ark My code: $list =~ s|$name||; # remove $name from the list if it's in the list $list =~ s|//|/|; # if $name was in the middle of the list, it would have left behind two /s, remove one $list =~ s|^/||; # if $name was at the front of the list, remove the leading / $list =~ s|/$||; # if $name was at the end of the list, remove the trailing /