Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Bug in script, regex help req extreme urgent

by karlgoethebier (Vicar)
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 exploiting the Monastery: (6)
As of 2015-07-06 02:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (69 votes), past polls