What about just $list =~ s|/?$name/?|| But you should be careful about that in case $name appears in the middle of a word e.g., cat and catmandu
perhaps $list =~ s|/?\b$name\b/?||; Tanton ----- Original Message ----- From: <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, December 11, 2002 2:49 PM Subject: Removing a name from a list - advanced regexp - TIMTOWTDI > 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 / > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]