Could not understand properly. Here is your code, with just print statements commented. I am getting correct output for all enteries, for all lines.
use strict; use warnings; my @input = ( "Figure <xref ref-type=\"fig\" rid=\"F1\">1</xref> Figure <xref re +f-type=\"fig\" rid=\"F1\">1</xref>", "Figure <xref ref-type=\"fig\" rid=\"F2\">2</xref>", "Figure <xref ref-type=\"fig\" rid=\"F3\">3</xref>" ); my $isize = scalar(@input); my ($same , $dx1 , $dx2); for (my $il = 0; $il < $isize; $il++ ) { $input[$il] =~ s/<xref ref-type="fig" rid=/\\protect\\customizeref +{/g; if ( $input[$il] =~ /\\protect\\customizeref{(.*?)<\/xref>/ ) { # $input[$il] =~ /<xref ref-type=" fig " rid=" ( . *? ) < \/xr +ef>/; #print("$1\n"); $_ = $1; $same = $1; $dx1 = /"(.*)"/; $dx1 = $1; $dx2 = />(.*)/; $dx2 = $1; #print("$dx1\n"); #print("$dx2\n"); $input[$il] =~ s/\\protect\\customizeref{$same<\/xref>/\\protect\\customizere +f{$dx1}{Figures}{}/g; $input[$il] =~ s/$same/$dx1}{Figures}{}/g; } if ( ( defined $same ) and ( defined $dx1 ) ) { #print(">$same\n"); $input[$il] =~ s/$same<\/xref>/$dx1}{Figures}{}/g; } print $input[$il], "\n"; }
Here is the output. Let me know if it is correct.
Figure \protect\customizeref{F1}{Figures}{} Figure \protect\customizer +ef{F1}{Figures}{} Figure \protect\customizeref{F2}{Figures}{} Figure \protect\customizeref{F3}{Figures}{}

In reply to Re: Multi replace in a Line by gurpreetsingh13
in thread Multi replace in a Line by veera

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.