Perhaps this isn't my very best day or i miss something essential - please feel free to correct me. But this seems to work...
#!/usr/bin/perl use strict; use warnings; undef $/; my $file = shift; my $module = shift; my $replace = shift; open ( my $fh, "<", $file); my $data = <$fh>; close $fh; print $data; print qq(\n\n\n); if ( $data =~ m/module $module/ ) { $data =~ s/$module/$replace/; } # ... # $data =~ s/$module/$replace/; print $data; __END__ Karls-Mac-mini:monks karl$ ./new.pl test.txt OLD "What are you doing? +" //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 //Verilog HDL for "tt", "hh" "functional" // if i write the word module here the script goofs up `timescale 1ps/10fs module What are you doing?(Y, A, B ); output Y; input A; input B; endmodule
Regards, Karl
«The Crux of the Biscuit is the Apostrophe»
In reply to Re: Bug in script, regex help req extreme urgent
by karlgoethebier
in thread Bug in script, regex help req extreme urgent
by sid.verycool
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |