Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Bug in script, regex help req extreme urgent

by karlgoethebier (Curate)
on Mar 09, 2013 at 15:15 UTC ( #1022578=note: print w/ replies, xml ) Need Help??


in reply to Bug in script, regex help req extreme urgent

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»


Comment on Re: Bug in script, regex help req extreme urgent
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1022578]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (11)
As of 2014-07-28 08:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (193 votes), past polls