good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re^3: Parsing a text file in Perl.by Athanasius (Archbishop) |
on May 26, 2014 at 11:11 UTC ( [id://1087420]=note: print w/replies, xml ) | Need Help?? |
If you want to match [==========] in a regex, you need to escape the square brackets — otherwise they form a character class. However, this approach cannot work: you are reading the data file line-by-line, which to Perl means from one newline (\n) to the next, but a typical line of input looks like this:
As can be seen, there are no lines which match [==========]. Likewise, the special regex character ^ matches at the beginning of a line, and neither [==========] nor tests appears at the beginning of a line. You will need a different strategy, along the lines outlined by hippo below. Hope that helps,
In Section
Seekers of Perl Wisdom
|
|