Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

How to change the input separator when we read a word file using perl? By default it fetches all the content before a newline in the input. how can we change that like using $/ for reading txt files?

  • Comment on Changing input separator while reading word file

Replies are listed 'Best First'.
Re: Changing input separator while reading word file
by moritz (Cardinal) on Oct 21, 2011 at 09:01 UTC
    How to change the input separator when we read a word file using perl?

    By assigning to $/.

    But if you mean "MS Office Word .doc file" when you say "word file", that won't help you much, because those are binary files, and do not use a fixed record separator. For reading binary files, you should use binmode and read. Or a CPAN module which does all the hard work for you. Or don't use .doc files in the first place.