The print command isn't executed because it's not in the regex. The first portion of the s/// (between the first two //'s) is a regex; the other portion could be considered a string. So you need to place the
(?{ print $1 }) at the end of the regex part, like so:
$str = "(<ref links=\" cit314-1 cit314-2 cit314-3 cit314-4 cit314-5\"/
+>)";
if( $str =~ s/<ref links="(.*?)"(.*?)\/>(?{ print $1, "\n" })/<ref lin
+ks="$1"$2><\/ref>/ ){
print "Match was found." . "\n";
}
print $str . "\n";
Notice I also didn't escape the quotes -- this isn't necessary and, I think, it makes things look a little messier.
elusion : http://matt.diephouse.com