Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: Extracting pattern from a file

by Corion (Patriarch)
on Apr 17, 2012 at 06:52 UTC ( [id://965444]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Extracting pattern from a file
in thread Extracting pattern from a file

So, what code have you written and how does it fail for your input data?

A good place to start might be something like the following. You will have to modify the regular expression to detect comments and you will have to add other cases you want to detect.

#!perl -w use strict; while (<DATA>) { s!\s+$!!; if( m!\btimescale\b! ) { print "Found timescale in [$_]\n"; } else { print "Ignored line [$_]\n"; }; }; __DATA__ =============================================== // 1st commented line //second commented line // timescale 1ns /5 ns timescale 1ns/4ns //this comment should also be ignored module modulename1 (a b c ) some lines.... some lines ... //third commented line //fourth commented line timescale 3ns/5ns module modulename2 (p q r) some lines ... //fifth comment //timescale 4ns/5ns timescale 1ns/3ns module modulename3 (m n p ) some line ... ================================================

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-23 17:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found