troubleshooting Question

How to parse a file that has code in it to identify a pattern in Perl?

Avatar of Tolgar
Tolgar asked on
Perl
4 Comments2 Solutions243 ViewsLast Modified:
Hi,
I would like to parse a file and return 1 or 0 based on the following condition:

If there is asterisk "*" in a line that  STARTS WITH "import" then it should return 0.

If there is NO asterisk "*" in a line that STARTS WITH "import" then it should return 1.
 

EXAMPLES:

The parser should return 1 for the following code: (because there is no asterisk in the lines that starts with import.)
import unit.verify
import unit.constraints.IsEqual

int x = 2*3;

Some more code in here

The parser should return 0 for the following code: (because there is asterisk in the lines that starts with import.))
import unit.verify
import unit.constraints.*

int x = 2*3;

Some more code in here


Can you please tell me how I can write this parse in Perl?


Thanks,
ASKER CERTIFIED SOLUTION
Fidelius

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros