The final version is in extract4.pl
Before: 84 lines
After: 34 lines
Fewer variables
Simpler control flow
No temporary files
More robust handling of inputs
Faster