in reply to content extraction

There are a number of ways to improve your script.

First, always use strictures (use strict; use warnings;). They pick up typos and give early warning of trouble ahead.

Always use the three parameter version of open which gives better security and makes the intent clearer. Check the result of opens and closes - again you get an early heads up about trouble. Use lexical file handles to better manage the life time of the opened file handle.

Never use $a or $b as general purpose variables - they are special and should only be used with sort. In fact, avoid single letter variable names in general - it's too easy to get them confused with each other.

Be consistent with your use of indentation and white space. PerlTidy is a really good tool - use it.

Avoid .*? in regular expressions. Instead use a negated character class: [^\n]*. Only capture stuff you actually want to use - it's more efficient and less confusing.


True laziness is hard work

Replies are listed 'Best First'.
Re^2: content extraction
by zzgulu (Novice) on Feb 24, 2009 at 13:25 UTC
    Thank you Beth, GrandFather, and Lawliet for your great points and prompt reply. I will keep them in mind. Lawliet, I used the other two patterns in case I want to test the results(like adding $1\t to print) to make sure I am capturing the right content. Regarding "exit", I guess you are right and it's extra. Thank you all again for your input