[LA.pm] global regex matches

David Heayn david at cloudgraphics.com
Thu Jun 30 22:08:01 PDT 2005


I'm having a little bit of trouble with trying to find and 
custom-replace all the URL references within an array.

I have this:

foreach (@recordsRaw)
	{
	my $thingie = $_;
	if ($thingie =~ /<a href="(http:\/\/.*?)">(.*?)<\/a>/ig)
		{
		my $tempURL;
		$tempURL = $1;
		open(STUFF, "+>>$linkDat");
		$rand = int(rand $maxN);
		my $rand2 = int(rand $maxN);
		my $encryptName = "$rand.$rand2";
		print STUFF "$encryptName|$tempURL\n";
		close(STUFF);
		$thingie =~ s/$tempURL/$redirLoc\?$encryptName/;
		push(@CleanArray, $thingie);
		}


but it only acts upon the first URL it finds.


BTW- I'm trying to track outbound links replacing 
"http://www.cnn.com" with "http://...redir?7584.2893"

P.S. - For once, I don't think $thingie clashes with any other variables.


David Heayn * http://www.cloudgraphics.com * 213/925.3283


More information about the Losangeles-pm mailing list