hi, i am trying to replace the following line in around 100 xml files :-
<value>javascript:var x=window.op +en('http://v3vi.click4assistance.co.uk/c4a.aspx?AccNo=Inter12109&amp; +IDENT=US-x&amp;Target=General&amp;Country=Singapore','_blank','menuba +r=no,location=no,resizable=yes,scrollbars=no,status=no');</value> + </item> "
I want to replace IDENT=US-x with IDENT=UK-x in all files ,only the value x is different in al files. I am trying to use the following code for it but I am not able to do it :-
#!/usr/bin/perl use strict; use File::Find; use Tie::File; my $input="C://data"; my $logfile="C:\log.txt"; find(\&filenames, $input); sub filenames() { if (-f $File::Find::name) { my $file=$File::Find::name; if($file=~m/\/data\//) { open(FILE, "$file"); my @filedata=<FILE>; close(FILE); my $datalength = scalar(@filedata); my $DCRContent=""; for (my $i=0;$i<$datalength; $i++) { if($filedata[$i]=~/(.*)(http:\/\/v3vi.click4assistance +.co.uk\/c4a.aspx\?AccNo=Inter12109&amp;IDENT=)(.*)(','_blank)(.*)/i) { print "$3 \n"; my $orig=$3; print "$orig \n"; $orig=~ s/US/UK/; print "The resulting value is : $orig \n"; $filedata[$i] = $1.$2."$orig".$4.$5; open(FILEOUTS,">>$logfile") or die("Opening file failed"); print FILEOUTS $file."\t"."\n"; close(FILEOUTS); } } open(FILEOUT,">$file") or die("Opening file failed"); print FILEOUT @filedata; close FILEOUT; } } }
basically i am able to replace us with UK and store it in $orig variable but with the next line "$filedata$i = $1.$2."$orig".$4.$5; " the entire line gets deleted except "IDENT=US-x&Target=General&Country=Singapore'" ,so how to really get the combined output ,i am bit new to perl so may be i am making a simple mistake ,i request the experts to pls guide regarding this issue , thanks in advance

In reply to regex issue by rahulgsp83

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.