in reply to Reading contents of file using regex

jesuashok there are some problems in your code.

You have not assigned any vales to $line

I don't know what are you doing in the below line, which is not necessary. Suppose you need to count the number of occurences, then it might be useful.

$line=~s/($book)/$1/ig;

Also change the below line

$t_book=~s/<(|/)(B|I|SC|U)>//ig;

into

$t_book=~s/<(\/)?(B|I|SC|U)>//ig; #to delete both opening and closing tags of bold italics etc.

GrandFather has highlighted clearly the other problems. Unless you give exact requirement you cannot get correct solutions. You will get answers only in assumptions.

Prasad