note
Punitha
<p>Hi,</p>
<p>I have tried to produce the exact output of yours with the same input, i got these codes,</p>
<c>
use strict;
while(<DATA>){
chomp;
$_=~s/(<citref idrefs=\")([^"]*)(\">)((?:(?!<\/citref>).)*)(<\/citref>)/$1.idgen($2,$4).$3.citeref($4).$5/sgie;
print "$_\n";
}
sub idgen{
my ($id,$idcon) = @_;
if($idcon =~/,/){
$idcon=~s/([^,]+)(?=,|$)/$id$1/gi;
$idcon=~s/,/ /gi;
}
else{
$idcon=$id.$idcon;
}
return($idcon);
}
sub citeref{
my ($con) = @_;
if($con =~/,/){
my (@con) = split/,/,$con;
map{s/[a-z]+/<it>$&<\/it>/i} @con;
$con =join(',',@con);
}
else{
$con =~s/[a-z]+/<it>$&<\/it>/gi;
}
return($con);
}
</c>
<br/>
<c>
__DATA__
<citref idrefs="cit">5c,5d</citref>
<citref idrefs="cit">5d</citref>
</c>
<p>But please explain us furthermore to provide you the better solution like,</p>
<ol>1. The content of the 'citref' tag (i.e) it will always contain the comma or not</ol>
<ol>2. The idrefs generated in the output should be preceded with the idref content of input or it will always be 'cit'</ol>
<p>Punitha</p>
670882
670882