我需要匹配rid="Vajravelu:1978"
和matchid="Vajravelu:1978"
這兩個相同的id。如何匹配兩個相同的id並導入所需的id
Perl程序下面工作提到邏輯
步驟1 首先mathcing兩個相同的id rid="Vajravelu:1978"
和matchid="Vajravelu:1978"
步驟2 如果兩個ID matchid =「Vajravelu相同:1978對應參考編號等id="j_zna-2014-0260_ref_001"
要被存儲在一個變量。
步驟3 此存儲的參考ID varible應寫入在RID = 'j_zna-2014-0260_ref_001'
步驟4 最後比賽ID應該被刪除
我輸入HTML文件:
<p>The sample ID [[<xref ref-type="bibr" rid="Vajravelu:1978">1</xref>, <xref ref-type="bibr" rid="Adesanya:2014">2</xref>]]</p>
<ref id="j_zna-2014-0260_ref_001"><label><matchid="Vajravelu:1978">[1]</label><mixed-citation><fnm>K.</fnm> <snm>Vajravelu</snm> and <fnm>K. S.</fnm> Sastri, J. Fluid Mech. <volume><bold>86</bold></volume>, 365 (1978).</mixed-citation></ref>
<ref id="j_zna-2014-0260_ref_002"><label><matchid="Narain:1982">[2]</label><mixed-citation>A. Narain and D. D. Joseph, Rheol. Acta. <bold>21</bold>, 228 (1982).</mixed-citation></ref>
我需要的輸出XML文件:
<p>The sample ID [[<xref ref-type="bibr" rid="j_zna-2014-0260_ref_001">1</xref>, <xref ref-type="bibr" rid="j_zna-2014-0260_ref_002">2</xref>]]</p>
<ref id="j_zna-2014-0260_ref_001"><label>[1]</label><mixed-citation><fnm>K.</fnm> <snm>Vajravelu</snm> and <fnm>K. S.</fnm> Sastri, J. Fluid Mech. <volume><bold>86</bold></volume>, 365 (1978).</mixed-citation></ref>
<ref id="j_zna-2014-0260_ref_002"><label>[2]</label><mixed-citation>A. Narain and D. D. Joseph, Rheol. Acta. <bold>21</bold>, 228 (1982).</mixed-citation></ref>
我的perl的編程初學者。我會嘗試下面提到的代碼。但是這個代碼不起作用。請指點
#!C:\Strawberry\perl\bin\perl
use strict;
use warnings;
open(IN,"$ARGV[0]\.html")||die("Input LaTeX filename without .html extension\n");
local $/;
my $TeX2html=<IN>;
my ($rid) = $TeX2html =~ m/rid="(.*?)"/;
my ($matchid) = $TeX2html =~ m/matchid="(.*?)"/;
while($rid = $matchid) {
$TeX2html =~ s/ref id="(.*?)/rid=$1/si;
}
print $TeX2html;
close(IN);
我使用命令來執行上述程序stack.pl sample >out.xml
首先'嚴格使用''使用警告;'應該是你的程序的第一行你的「shebang」行是錯誤的 - 但這並不是' (你應該提供解釋器的路徑,例如'C:\ Strawberry \ perl \ bin \ perl') – Sobrique