![]() |
|
No such thing as a small change | |
PerlMonks |
Re^3: Regular Expression to Parse Data from a PDFby kcott (Bishop) |
on Feb 28, 2020 at 06:28 UTC ( #11113532=note: print w/replies, xml ) | Need Help?? |
'They might add a "R-1" or "R-2" to the far left column if there is a revision.' You just need to extend the regex to handle that. Here's an example:
Output:
print ... $fields[1] . ",". $fields[3] . ",". $fields[4] . ",". ... Here's an example to show a better way to handle that:
On an unrelated note, there are problems with your open statements. Use of package variables can lead to all sorts of bugs that are hard to track down. Your six error messages are identical: how will you know which file generates "Can't open the output file ...". Look to using lexical filehandles and the 3-argument form of open. Consider the autodie pragma — you'll do less work and get better error reporting. — Ken
In Section
Seekers of Perl Wisdom
|
|