Think about Loose Coupling | |
PerlMonks |
To find and count a repeating pattern in a lineby punitpawar (Sexton) |
on Feb 08, 2016 at 19:24 UTC ( [id://1154665]=perlquestion: print w/replies, xml ) | Need Help?? |
punitpawar has asked for the wisdom of the Perl Monks concerning the following question:
Hello, I wanted to know if there is any way by using regular expression to count the occurrences of a repeating pattern in a line ? here is the problem statement Given a log file: some garbage...from:123.54,78.21...more garbage..to:56,82,124.54...more some more garbage...from:11.54,45.84...garbage..to:115.87,98.65 ... Assumption: these coordinates will always appear in sequence: from ... to... from ... to... But these from - to pair may or may not be on same line Write a script to return pairs of (from, to) coordinates. The only way I could think of was by splitting the line....But I feel there should be a better way. here is my code below This is the sample input file abc.txt And the output I am expecting is
Back to
Seekers of Perl Wisdom
|
|