Hi all, i need to debug this script and make it work according to my requirement. This is an urgent requirement, i need to fix this asap.

The concept of the script was to replace "oldname" written after the word "module" with "newname" This worked well until the word module came in the comment. CONTENT OF SCRIPT
#!/usr/bin/perl -w BEGIN {undef $/;} # I TRIED 1ST my $match = "^module.*?$ARGV[2].*?([\\(;])"; 2ND my $mat +ch = "\^module.*?$ARGV[2].*?([\\(;])"; 3RD my $match = "\\^module.*?$ +ARGV[2].*?([\\(;])" my $match = "module.*?$ARGV[2].*?([\\(;])"; #print "$match"; my $filename = $ARGV[0]; open (INFILE, "<", $filename) or die "Failed to read file $filename +: $! \n"; $string = <INFILE>; close INFILE; #I ALSO TRIED "$string =~ s/^$match/module $ARGV[1]$1/sg;"; $string =~ s/$match/module $ARGV[1]$1/sg; open OUTFILE, ">$ARGV[0]" || die "Failed to create $ARGV[0]\n"; print OUTFILE ($string); close OUTFILE;
what this script does to input file is : CONTENT OF BEFORE SCIPT IS RUN ON FILE
//Verilog HDL for "tt", "hh" "functional" // if i write the word here the script goofs up `timescale 1ps/10fs module OLD(Y, A, B ); output Y; input A; input B; endmodule
NOW I RUN script.pl FILE NEW OLD now the CONTENT OF FILE BECOMES
//Verilog HDL for "tt", "hh" "functional" // if i write the word here the script goofs up `timescale 1ps/10fs module NEW(Y, A, B ); output Y; input A; input B; endmodule
which is good but if i write the word "module" in the comment line i.e. CONTENT OF BEFORE SCrIPT IS RUN ON FILE which goofs up
//Verilog HDL for "tt", "hh" "functional" // if i write the word module here the script goofs up `timescale 1ps/10fs module OLD(Y, A, B ); output Y; input A; input B; endmodule

Now the contents become
//Verilog HDL for "tt", "hh" "functional" // if i write the word module NEW(Y, A, B ); output Y; input A; input B; endmodule
which is unacceptable to me. plz help guys,

In reply to Bug in script, regex help req extreme urgent by sid.verycool

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.