in reply to Extracting pattern from a file

Since your code looks almost like Verilog, have you considered using a Verilog parser? Verilog-Perl and vppreproc in particular may help you weed out comments.

Also, the Verilog $printtimescale system task can be used inside Verilog source code to show the timescale for each module.