I have a file that contains hashtags (on a single line). Some of them may be repeated and non-adjacent, e.g. "#tag1 #tag2 #tag3 #tag1". I can detect duplicates with this:
$tags=~/(#\S+).+$1/;
But I fail to remove the duplicate with the line below. What am I doing wrong?