i have $a in which there are hundered of urls appended by "," now what i want to do is to get one url in $b and then compare it with $a wether it exists in $a.

there are number of errors occuring due to meta characters present in URLS. as i am fetching these urls from net and appending it in $a.but i append only that URL in $a which does not exist in $a. that is why i am comparing first it with $a variable.

You could create a hash with URLs, like my %URLs; $URLs{$b} = 1 unless exists $URLs{$b}; Yyou could even count the number of time specific URL has been used: $URLs{$b}++; # Without condition In the end you can loop through all the URLs by foreach ($key = keys(%URLs)) {}

Another option is to create an array with all the URLs and loop through the array with eq